473,505 Members | 16,940 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why is DBL_MIN != nextafter(0.0,1.0) ??

The output of the following program
----------------------------------------------------------
#include <iostream>
#include <iomanip>
#include <float.h>
#include <fpu_control.h>
#include <math.h>

using namespace std;

int main()
{
cout << setprecision(20);

cout << nextafter(0.0, 1.0) << endl;
cout << DBL_MIN << endl;
cout << LDBL_MIN << endl;
}
------------------------------------------------------------
is this:

4.9406564584124654418e-324 // The next double after zero ...
2.2250738585072013831e-308 // is not the "smallest
representable double"
3.3621031431120935063e-4932

Compiled with g++. g++ -v says "gcc version 4.1.2 20060928".

Feb 1 '07 #1
2 3248
<ja****@gmail.comwrote in message
news:11**********************@a75g2000cwd.googlegr oups.com...
The output of the following program
----------------------------------------------------------
#include <iostream>
#include <iomanip>
#include <float.h>
#include <fpu_control.h>
#include <math.h>

using namespace std;

int main()
{
cout << setprecision(20);

cout << nextafter(0.0, 1.0) << endl;
cout << DBL_MIN << endl;
cout << LDBL_MIN << endl;
}
------------------------------------------------------------
is this:

4.9406564584124654418e-324 // The next double after zero ...
2.2250738585072013831e-308 // is not the "smallest
representable double"
3.3621031431120935063e-4932

Compiled with g++. g++ -v says "gcc version 4.1.2 20060928".
DBL_MIN is the smallest *normalized* value of type double. IEEE 754
arithmetic supports denormalized values that, demonstrably, can be
much smaller.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Feb 1 '07 #2
Hi

ja****@gmail.com wrote:
4.9406564584124654418e-324 // The next double after zero ...
2.2250738585072013831e-308 // is not the "smallest
representable double"
3.3621031431120935063e-4932
DBL_MIN is the smallest _normalized_ positive floating point number.
Denormalized numbers can become smaller by a factor of 2^(nr of bits in
the mantissa) (because they assume the numbers are +/- 0.mantissa *
2^exp instead of +/- 1.mantissa * 2^exp). Calculating the quotient in
your example yields 2^-51.9999999999 which matches the 52 bits in the
mantissa of IEEE 754 double precision numbers.

See also http://en.wikipedia.org/wiki/IEEE_754#Cases

hth
Markus
Feb 1 '07 #3

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

Similar topics

0
1319
by: jcwhui | last post by:
I have problems on storing dbl_min into a "DOUBLE PRECISION" column in Oracle 9.2 (via ODBC). dbl_min is 2.2250738585072014E-308 in case you don't know. The problem is Oracle rounds it to 0.0. ...
29
16685
by: Peter Ammon | last post by:
What's the most negative double value I can get? Is it always guaranteed to be -DBL_MAX? If so, why (or rather, where)? Thanks.
13
5114
by: Peter Ammon | last post by:
I have a floating point number. I'd like to get the nearest floating point number that is larger or smaller than the given number. I investigated FLT_EPSILON but it only seems to be useful if the...
7
2564
by: Daniel Vallstrom | last post by:
I am having trouble with floating point addition because of the limited accuracy of floating types. Consider e.g. x0 += f(n) where x0 and f are of some floating type. Sometimes x0 is much larger...
27
3801
by: Daniel Vallstrom | last post by:
I'm having problems with inconsistent floating point behavior resulting in e.g. assert( x > 0.0 && putchar('\n') && x == 0.0 ); holding. (Actually, my problem is the dual one where I get...
32
4944
by: priyam.trivedi | last post by:
Hi! Could anyone tell me how to find the square root of a number without using the sqrt function. I did it by using Newton's Formula. How can it be done by using the Binomial Theorem/Taylor...
2
1195
by: janzon | last post by:
Hello! Suppose x is a double not equal to Inf or NaN. How can I find the smallest double y, such that x<y? It would be nice not having to deal with bits, big and little endian and so forth. (But...
37
16177
by: The87Boy | last post by:
Hey all I have a problem with float I should write a program, where you are getting some numbers from the command-line and try to find the maximum and minimum-values of these numbers. I need...
17
5191
by: spooler123 | last post by:
Just a small little program. Can not figure out what am I doing wrong. #include <stdio.h> #include <limits.h> #include <float.h> int main() { double max = FLT_MAX;
0
7103
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.