Skip to content
Tcl Source Code History Of Ticket 62144fdc02
Login

History Of Ticket 62144fdc02

Artifacts Associated With Ticket 62144fdc02

  1. Ticket change [84fd588d06] (rid 255034) by oehhar on 2026-07-21 11:00:57:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      I tried a bit with doubles, scan and format with NaN and stumbled over the following:
      
      <verbatim>
      % scan NaN %f
      {}
      % scan NaN %f fl
      0
      % set fl
      can't read "fl": no such variable
      </verbatim>
      
      For sure it is a bug:
      
         *   that "scan NaN %f" returns a list with one element with the empty string
      
      As NaN is a valid value for a double, it would be beneficial for me, that "scan NaN %f" really scans a double with a NaN value.
      
      Apparently, TCL does not see "NaN" as a double value. "INF" works for scan, format, expr.
      
      Even if there is no way to generate a NaN within TCL, it may come from an external source like a data base.
      
      Thanks for all,
      Harald
      
    5. foundin initialized to: "8.6-9.1"
    6. is_private initialized to: "0"
    7. login: "oehhar"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "0f366eb3e9e2fcab52b8ebacd197db9047186a5f"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "oehhar"
    14. subsystem initialized to: "18. Commands M-Z"
    15. title initialized to: ""scan NaN %f" returns a list with an empty element"
    16. type initialized to: "Bug"
  2. Ticket change [e10b763a5d] (rid 255038) by kuehro on 2026-07-24 07:45:26:

    1. icomment:
      There are two ways to fix the deficient math of our beloved Tcl:
      
      1) Build your own Tcl with line 26 of generic/tclInt.h changed to 
      
      #define ACCEPT_NAN
      
      
      2) Download mymath.tcl from 
      
      https://gist.github.com/yyamasak/b1ce55c40631b1c1ea6e8200dba3f7e0
      
      and change line 109 from
      
      		if {$res eq "domain error: argument not in valid range"} {
      
      
      to
      
      
      		if {$res eq "domain error: argument not in valid range" || \
      		   [string first "non-numeric" $res] > 0}  {
      
      
      Now you can use myexpr instead of expr, for example with 8.6.18 and 9.1b1 we get:
      
      % set $n -nan
      -nan
      % puts [myexpr {2.0+$n}]
      NaN
      % puts [myexpr {1.0/0.0}]
      Inf
      % puts [myexpr {0.0/0.0}]
      NaN
      
      
      Searching for nan at https://core.tcl-lang.org/tips/doc/trunk/index.md
      shows several TIPs related to proper math handling (520,521, 731, ...).
      Method 1) still has inconsequent handling of the sign, i.e. -NaN vs NaN 
      and method 2) can be used without recompiling but needs myexpr instead 
      of expr.
      Working in a scientific workplace I had to abandon the use of Tcl for this
      reason but for many use cases method 1) or 2) might be viable.
      
      Good luck,
      
      Kai-Uwe
      
    2. login: "kuehro"
    3. mimetype: "text/plain"
  3. Ticket change [fcf8a11521] (rid 255039) by oehhar on 2026-07-24 07:58:45:

    1. icomment:
      Thanks, Kai-Uwe, for the great hints and TIP pointers.
      I have apparently hit a difficult point.
      That explains why nobody adds comments.
      
      But the reason of this ticket is the return of an list with an emty string element by
      
      <verbatim>
      scan NaN %f
      </verbatim>
      
      So, NaN is represented here by the empty string.
      
      But
      
      <verbatim>
      scan NaN %f fl
      </verbatim>
      
      does not scan NaN as the empty string.
      
      This is inconsistent.
      
      Sorry to hear, that you had to abandon TCL due to missing nan support.
      Yes, there is now a "isnan()" command which might be the first step.
      
      And the documentation of scan/format do not mention +/-Inf neither, which works.
      
      Thanks for all,
      Harald
      
    2. login: "oehhar"
    3. mimetype: "text/x-fossil-wiki"
    4. username: "oehhar"
  4. Ticket change [7660028867] (rid 255040) by kuehro on 2026-07-24 08:56:42:

    1. icomment:
      Using a fossil checkout from today and compilation with #define ACCEPT_NAN leads to:
      
      
      (tcltest) 1 % scan NaN %f
      NaN
      (tcltest) 2 % scan NaN %f fl
      1
      (tcltest) 3 % set fl
      NaN
      (tcltest) 4 % scan -nan %f fl
      -NaN
      (tcltest) 15 % expr {isnan($fl)}
      1
      (tcltest) 6 % info patchlevel
      9.1b1
      
      Looks Good.
      
      Kai-Uwe
      
    2. login: "kuehro"
    3. mimetype: "text/plain"
  5. Ticket change [698a7f9327] (rid 255041) by oehhar on 2026-07-24 09:21:25:

    1. icomment:
      I added a forum to TIP 520 and wrote a message on tcl-core:
      
      [https://core.tcl-lang.org/tips/forumpost/990033f3]
      
      Please use the forum to post any information outside this bug.
      We risk to loose the information if the bug is closed.
      
      Thanks for all,
      Harald
      
    2. login: "oehhar"
    3. mimetype: "text/x-fossil-wiki"
    4. username: "oehhar"