This is the mail archive of the
cygwin
mailing list for the Cygwin project.
RE: Floating point exception in strtod()
- From: "Soegtrop, Michael" <michael dot soegtrop at intel dot com>
- To: "dank at kegel dot com" <dank at kegel dot com>, "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Sun, 8 Apr 2018 12:57:19 +0000
- Subject: RE: Floating point exception in strtod()
- Dlp-product: dlpe-windows
- Dlp-reaction: no-action
- Dlp-version: 11.0.0.116
- References: <dd5e98ea-8f39-1c4b-116c-37968cb3a52d@cornell.edu> <CAPF-yOboiR8Dg+QtrHCCR55vPGysMxQ=Wbpa4QGaJ=i5PoqtkQ@mail.gmail.com>
> 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