From: SourceForge.net <no...@so...> - 2005-01-25 15:20:46
|
Bugs item #532537, was opened at 2002-03-20 11:03 Message generated for change (Comment added) made by kennykb You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=532537&group_id=10894 Category: 11. Conversions from String Group: obsolete: 8.3.4 Status: Open Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) >Assigned to: Kevin B KENNY (kennykb) Summary: Buggy Windows strtod() ? Initial Comment: Try following script under Window NT: proc testDouble {} { set a0 [expr {double(2.63624325102e-308)}] set b [expr {double(0.19024736769)}] set a $a0 set count 30 while {[incr count -1] > 0} { # just make a lose its double repr # string length $a puts "a = $a" set a [expr {$a*$b}] } } a is decreasing until 0.0. Now uncomment the [string length] line, and try it again. This gives the error message: can't use non-numeric string as operand of "*" (Is it possible to have "floating-point value too small to represent" ?) This work fine under Linux. Can I conclude that my Windows NT strtod() is buggy ? ---------------------------------------------------------------------- >Comment By: Kevin B KENNY (kennykb) Date: 2005-01-25 10:20 Message: Logged In: YES user_id=99768 This problem is in the scope of TIP #132 - assigning it to myself. The fix may be as simple as including strtod.obj in COMPAT_OBJS, depending on whether compat/strtod.c has the same bug. But depending on the native C library in this area has proven to be a mistake; FP conversion bugs have been recurrent. ---------------------------------------------------------------------- Comment By: Eric Boudaillier (beric) Date: 2002-03-25 08:09 Message: Logged In: YES user_id=493507 Being surprised to found in <float.h> #define DBL_MIN 2.2250738585072014e-308 I have tried a c code declaring two double: 2.63624325102e-308 5.01538339097e-309 It compile on both windows and linux, linux strtod() works with both string repr, windows (VC6) fails with errno == ERANGE for the second. The following page show that doubles have normalized and denormalized representation: http://babbage.cs.qc.edu/courses/cs341/IEEE- 754references.html DBL_MIN is the minimum normalized double. It looks like windows's strtod() doesn't work on denormalized double, whereas linux does. ---------------------------------------------------------------------- Comment By: Donal K. Fellows (dkf) Date: 2002-03-25 05:51 Message: Logged In: YES user_id=79902 Can duplicate this in 8.3.4 under Solaris/SPARC as long as I remember to uncomment the [string length] (which acts as a complete destroyer of the double rep, as it converts to the wide-character internal rep) ---------------------------------------------------------------------- Comment By: Eric Boudaillier (beric) Date: 2002-03-25 03:16 Message: Logged In: YES user_id=493507 Have you uncommented the [string length] line ? % expr {double(4.94065645841e-324)} floating-point value too small to represent % expr {double(5.92665091618e-317)} floating-point value too small to represent with both AS 8.3.4.1 and 8.4a4 compiled with VC6 on two NT 4 station. ---------------------------------------------------------------------- Comment By: Jeffrey Hobbs (hobbs) Date: 2002-03-22 19:09 Message: Logged In: YES user_id=72656 perhaps ... but I get the following on Win2K with a VC++6 compiled 8.3.4 (ActiveTcl 8.3.4.2): (tkcon) 50 % testDouble a = 2.63624325102e-308 a = 5.01538339097e-309 a = 9.54163488088e-310 a = 1.81527091955e-310 a = 3.45350514088e-311 a = 6.57020262356e-312 a = 1.24996375432e-312 a = 2.37802313969e-313 a = 4.52412642615e-314 a = 8.60703143633e-315 a = 1.63746507553e-315 a = 3.1152341918e-316 a = 5.92665091618e-317 a = 1.12752993739e-317 a = 2.14509469586e-318 a = 4.08098223465e-319 a = 7.76374755875e-320 a = 1.47725628107e-320 a = 2.81123352484e-321 a = 5.33590897509e-322 a = 1.03753785627e-322 a = 1.97626258336e-323 a = 4.94065645841e-324 a = 0.0 a = 0.0 a = 0.0 a = 0.0 a = 0.0 a = 0.0 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=532537&group_id=10894 |