Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1873 [string is double] accepts 'd' and 'D'

obsolete: 8.3.4
closed-wont-fix
Don Porter
5
2006-03-10
2002-05-01
John Seal
No

[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

Discussion

  • 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.

     
    • summary: [string is double] accepts "d" and "D" --> [string is double] accepts "d" and "D"
    • status: open --> pending-wont-fix
     
  • John Seal
    John Seal
    2002-05-02

    • summary: [string is double] accepts "d" and "D" --> [string is double] accepts "d" and "D"
    • status: pending-wont-fix --> open-wont-fix
     
  • John Seal
    John Seal
    2002-05-02

    Logged In: YES
    user_id=231769

    Seems to work OK with "d" present:

    % expr 1.23d4 + 0.7d4
    19300.0

     
    • labels: 105659 --> 53. Configuration and Build Tools
    • assigned_to: dkf --> hobbs
    • summary: [string is double] accepts "d" and "D" --> [string is double] accepts "d" and "D"
     
  • 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...

     
    • summary: [string is double] accepts "d" and "D" --> [string is double] accepts 'd' and 'D'
     
  • Don Porter
    Don Porter
    2006-03-10

    Logged In: YES
    user_id=80530

    This is fixed in Tcl 8.5
    with the use of strtod()
    removed.

     
  • Don Porter
    Don Porter
    2006-03-10

    • assigned_to: hobbs --> dgp
    • status: open-wont-fix --> closed-wont-fix