Artifacts Associated With Ticket 62144fdc02
Ticket change [84fd588d06] (rid 255034) by oehhar on 2026-07-21 11:00:57:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- 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 - foundin initialized to: "8.6-9.1"
- is_private initialized to: "0"
- login: "oehhar"
- priority initialized to: "5 Medium"
- private_contact initialized to: "0f366eb3e9e2fcab52b8ebacd197db9047186a5f"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "oehhar"
- subsystem initialized to: "18. Commands M-Z"
- title initialized to: ""scan NaN %f" returns a list with an empty element"
- type initialized to: "Bug"
Ticket change [e10b763a5d] (rid 255038) by kuehro on 2026-07-24 07:45:26:
- 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 - login: "kuehro"
- mimetype: "text/plain"
- icomment:
Ticket change [fcf8a11521] (rid 255039) by oehhar on 2026-07-24 07:58:45:
- 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
- login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- username: "oehhar"
- icomment:
Ticket change [7660028867] (rid 255040) by kuehro on 2026-07-24 08:56:42:
- 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 - login: "kuehro"
- mimetype: "text/plain"
- icomment:
Ticket change [698a7f9327] (rid 255041) by oehhar on 2026-07-24 09:21:25:
- 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
- login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- username: "oehhar"
- icomment: