using maximum value of double and int.

A

Amit

Hi,
I am using gcc 3.3 I am writing a code in c++, parts of which I have
been using before(on gcc 3.1) and did not have any problems.
However, I notice that I have defined stuff like:

const double LARGE=1.e30;

Is this valid? I have not had any problem with this, but I am not sure
if this is the correct way of defining a large or a small value.

any comments: what is a better way to do this?

thanks,
amit.
 
V

Victor Bazarov

Amit said:
I am using gcc 3.3 I am writing a code in c++, parts of which I have
been using before(on gcc 3.1) and did not have any problems.
However, I notice that I have defined stuff like:

const double LARGE=1.e30;

Is this valid?

Seems fine.
> I have not had any problem with this, but I am not sure
if this is the correct way of defining a large or a small value.

Whatever works for you...
any comments: what is a better way to do this?

You can always use 'std::numeric_limits<double>::max()' to initialise
a "rather large" double value. You can't increase it afterwards, though.
So, if you need to multiply it with something or calculate its square for
whatever reason, you might want to take a square root of that value...

V
 
K

Kyle

Amit said:
Hi,
I am using gcc 3.3 I am writing a code in c++, parts of which I have
been using before(on gcc 3.1) and did not have any problems.
However, I notice that I have defined stuff like:

const double LARGE=1.e30;

Is this valid? I have not had any problem with this, but I am not sure
if this is the correct way of defining a large or a small value.

any comments: what is a better way to do this?

thanks,
amit.

#include <limits>

const double dMax = std::numeric_limits<double>::max();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top