This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Floating point exception in strtod()


> Probably doesn't fit precisely into a double.  Does strtold behave
> better?

actually both numbers can be represented exactly as IEEE double. In Maxima:

(%i1)	factor(121645100408832000);
(%o1)	2^16*3^8*5^3*7^2*11*13*17*19
(%i2)	float(log(3^8*5^3*7^2*11*13*17*19)/log(2));
(%o2)	40.75545582601886

(%i3)	factor(221645100408832000);
(%o3)	2^16*5^3*31*41*1361*15641
(%i4)	float(log(5^3*31*41*1361*15641)/log(2));
(%o4)	41.62102908434535

So the first number has 41 bits and the second 42 after removing powers of 2. The significand size of a double is 53 bits (including the implicit 1).

Best regards,

Michael
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]