News for hackers. Stuff that matters.
Re:Issues with porting C++ code to a 64-bit platform by peripetylabs on Monday April 01, 2013 @05:09PM (#5475947)
One way to avoid loss of precision in the conversion is to check if the number of digits in the integer is larger than the constant DBL_DIG (defined in <cfloat>) -- numbers with less digits than that constant can be safely converted to the 'double' type and back.
Re:Issues with porting C++ code to a 64-bit platform by thwest on Monday April 01, 2013 @05:53PM (#5476199)
Note that DBL_DIG is the number of decimal digits that can be a 9. If the max integral value storable in a double is 4,000,000, DBL_DIG would only be 6. It is a conservative limit.