473,322 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

using maximum value of double and int.

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.

Aug 18 '05 #1
2 38708
Amit wrote:
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

Aug 18 '05 #2
Amit wrote:
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();
Aug 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: K. Davis | last post by:
I need to increment the maximum value of a field of a table by 1 when a form opens a blank record. (e.g. =max(!![trip_number}) so the logic and references are working at the form level. I've...
5
by: Sunny123 | last post by:
hello i am trying to find the maximum value of a function and where it occur. i.e there is an array x |y ============= | |
29
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is:...
3
by: Madmartigan | last post by:
Hello I have the following task but am battling with the final output. How do I keep two different vectors in sync and how would I retrieve the index for the maximum value of one of the vectors??...
2
by: Pugi! | last post by:
hi, I am using this code for checking wether a value (form input) is an integer and wether it is smaller than a given maximum and greater then a given minimum value: function...
6
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I'm using the VScrollBar and set it as follow: m_vScrollBar.Minimum = -19602; m_vScrollBar.Maximum = 0; m_vScrollBar.SmallChange = 1; m_vScrollBar.LargeChange = 1089; m_vScrollBar.Value =...
2
choke
by: choke | last post by:
I need to write a function in devc++ that creates an array of n integers, each element is equal to n*n+i*i-n*i where i is from 0 to n-1 as the array index. Within the same function I need to find...
0
by: Fredrik Lundh | last post by:
maurizio wrote: What kind of file is it? Did you pick numpy because you want to do matrix operations (beyond just finding a maximum value), or was it just the first thing you stumbled upon...
1
by: maurizio | last post by:
thank you for your answer actually i've to do some statistics (maximum,minimum,mean,standard deviation,....) of a file of data in which each column is a particular type of data. (the file is a tab...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.