[string is double] accepts 'd' and 'D'
Closed / Wont Fix551154ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 21 years ago
Descriptionplain2002-05-01 20:46:51
[string is double] accept "d" or "D" at some places within a number, but not at others. % info patchlevel 8.3.4 (bin) 2 % string is double 1234 1 (bin) 3 % string is double d1234 0 (bin) 4 % string is double 1d234 1 (bin) 5 % string is double 12d34 1 (bin) 6 % string is double 123d4 1 (bin) 7 % string is double 1234d 0 (bin) 8 % string is double 1d2d3d4 0 (bin) 9 % string is double 1D234 1 I don't think the "d" is being interpreted as the radix point; see the examples below. Kevin Kenny suggests "d" may be allowed as a synonym for "e" to mark the exponent, and that seems consistent with the behavior. % parray tcl_platform tcl_platform(byteOrder) = littleEndian tcl_platform(machine) = intel tcl_platform(os) = Windows NT tcl_platform(osVersion) = 4.0 tcl_platform(platform) = windows tcl_platform(user) = sealj (bin) 2 % string is double 1.234 1 (bin) 3 % string is double 1.2d34 1 (bin) 4 % string is double 1.23d4 1 (bin) 5 % string is double 1.234d 0 (bin) 6 % string is double 1.d234 1
dkfplain2002-05-02 16:02:21
Logged In: YES user_id=79902 It looks like your platform's strtod() thinks that 'd' (for double?) is a synonym for 'e'; it might accept 'f' too (for float.) Can Tcl actually perform arithmetic operations on 1.23d4 ? If so (easier for you to check than me as my libc doesn't know the format) then I'll leave it for now since the point of [string is] is really to check whether Tcl will barf on the string later on.
johnsealplain2002-05-02 18:52:46
Logged In: YES user_id=231769 Seems to work OK with "d" present: % expr 1.23d4 + 0.7d4 19300.0
dkfplain2002-05-02 19:52:11
Logged In: YES user_id=79902 Oh well, fixing this (if it is even something that should be fixed, which I personally doubt since some people might expect it to work given their platform's strtod() behaviour) would require using the right "compatability" strtod() implementation, which is an area I don't understand. Handing off to Jeff who can resolve this as he sees fit, either by modifying the documentation or by modifying makefile.vc to ask for the compat version of strtod(). As a side note, the Tcl_GetDoubleFromObj manpage could do with the format of an acceptable string shifting over from Tcl_GetDouble...
dkf Ticket [551154ffff]: 1 change
[History diff]2003-02-25 16:26:22
dgpplain2006-03-10 23:02:00
Logged In: YES user_id=80530 This is fixed in Tcl 8.5 with the use of strtod() removed.
Log in (anonymous is fine) to add a comment.