Artifacts Associated With Ticket 218000
Ticket change [11541bc307] (rid 95115) by nobody on 2000-10-26 00:51:50:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 680 Bug Version: 8.0p2 SubmitDate: '1998-09-23' LastModified: '1999-09-15' Severity: LOW Status: Closed Submitter: welch ChangedBy: hobbs OS: All OSVersion: NA Machine: NA FixedDate: '2000-10-25' FixedInVersion: NA ClosedDate: '1999-09-15' I've got a program that returns the floating point number HUGE_VAL to Tcl. Unfortunately, libc represents this as "Inf" which Tcl cannot convert back into a floating point number. Here's an example: - "$myobj" is an instance of a class I've created - "$myobj hugeVal" just returns the defined constant HUGE_VAL - "$myobj setIt" tries to convert the parameter via Tcl_GetDouble % $myobj hugeVal Inf % set val [$myobj hugeVal] Inf % set a [expr $val / 10] syntax error in expression "Inf / 10" % $myobj setIt $val expected floating-point number but got "Inf" The actual code for the "hugeVal" function looks like: case 32: { // double hugeVal(void) double _retcode; if (_argc != 2) { _interp->result = "wrong # args"; return TCL_ERROR; } _retcode = HUGE_VAL; sprintf(_interp->result,"%f",_retcode); } break; Brian ( [email protected] ) The problem is that sprintf does the interp here, converting it to a regular string "Inf". Code like this should benefit from Tcl_Obj's, where it needn't be stored as a string. -- 09/15/1999 hobbs - foundin initialized to: "obsolete: 8.0p2"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "69. Other"
- title initialized to: ""Inf" not understood in expr"
- type initialized to: "Bug"
Ticket change [9c4796593f] (rid 96122) by welch on 2000-10-26 08:12:11:
- closedate changed to: "2000-10-26T01:12:11"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [e96627949a] (rid 104815) by dgp on 2001-04-16 20:52:08:
- closedate changed to: "2001-04-16T13:52:08"
- closer changed to: "dgp"
- resolution changed to: "Invalid"
- subsystem changed to: "None"
- title changed to: ""Inf" not understood in expr"
Ticket change [0c7857739f] (rid 114183) by nobody on 2001-08-10 19:51:32:
- icomment:
Logged In: NO I wanted to add some thing more to this. If test case like this. tcl> set a INF tcl>if{($a == "*")} { } It's giving floating-point value too large. Please comment on this. This is only on HPUX platform only. - login: "nobody"
- mimetype: "text/plain"
- username: "nobody"
- icomment:
Ticket change [d38b47524d] (rid 123307) by dgp on 2001-08-10 23:16:00:
- status changed to: "Open"
Ticket change [ae9e7c8077] (rid 101671) by dgp on 2001-08-10 23:16:01:
- icomment:
Logged In: YES user_id=80530 Re-opening this so we can address the new HPUX comment. Need to examine cross-platform inconsistency of [expr] -- probably due to inconsistency of strtod() or something similar.
- login: "dgp"
- mimetype: "text/plain"
- subsystem changed to: "45. Parsing and Eval"
- title changed to: ""Inf" not understood in expr"
- username: "dgp"
- icomment:
Ticket change [c79533bbb1] (rid 121954) by dgp on 2001-08-10 23:16:29:
- assignee changed to: "msofer"
- title changed to: ""Inf" not understood in expr"
Ticket change [3456dff99f] (rid 106746) by msofer on 2001-08-14 21:04:37:
- assignee changed to: "hobbs"
- title changed to: ""Inf" not understood in expr"
Ticket change [d44ed00c49] (rid 123419) by hobbs on 2002-02-26 05:16:36:
- assignee changed to: "dgp"
- icomment:
Logged In: YES user_id=72656 SuSE 7.3 build of 2002-02-25 8.4 build also gives: % expr {"INF"} floating-point value too large to represent That actually seems correct to me in some sense. - login: "hobbs"
- mimetype: "text/plain"
- title changed to: ""Inf" not understood in expr"
- username: "hobbs"
Ticket change [236fb602da] (rid 130933) by dgp on 2002-02-26 07:08:56:
- icomment:
Logged In: YES user_id=80530 This is weird though: % set a INF INF % expr {$a + 1} can't use floating-point value as operand of "+" - login: "dgp"
- mimetype: "text/plain"
- title changed to: ""Inf" not understood in expr"
- username: "dgp"
- icomment:
Ticket change [8f29cc2ceb] (rid 120239) by dgp on 2002-07-06 03:47:38:
- assignee changed to: "dkf"
- icomment:
Logged In: YES user_id=80530 Error message is improved now: % set a Inf Inf % expr {$a + 1} floating-point value too large to represent The original report has a better error message now too: % expr $a + 1 syntax error in expression "Inf + 1": variable references require preceding $ so there appears to be a consistency here. Open issues: 1) Is this consitency cross-platform? 2) Is documentation sufficient? - login: "dgp"
- mimetype: "text/plain"
- subsystem changed to: "16. Commands A-H"
- title changed to: ""Inf" not understood in expr"
- username: "dgp"
Ticket change [735de7ab4f] (rid 105035) by dkf on 2002-07-06 05:35:22:
- assignee changed to: "msofer"
- icomment:
Logged In: YES user_id=79902 Hmm. The expression parser probably doesn't know about Inf (or NaN either.)
- login: "dkf"
- mimetype: "text/plain"
- subsystem changed to: "45. Parsing and Eval"
- title changed to: ""Inf" not understood in expr"
- username: "dkf"
Ticket change [4855984250] (rid 99865) by dgp on 2002-07-22 07:54:12:
- icomment:
Logged In: YES user_id=80530 another data point on this: Tcl is not consistent in treating Inf and Nan: % expr {"nan"} domain error: argument not in valid range % expr {nan} domain error: argument not in valid range % expr {"inf"} floating-point value too large to represent % expr {inf} syntax error in expression "inf" The difference is due to line 1555 of tclParseExpr.c which specially looks for 'n' or 'N' to give strtod() a chance to claim it. It would be more consistent to either check for 'i' and 'I" there as well, or to check for none of them. Given the original report here, the better choice is probably to check for both so that all string reps of doubles generated by Tcl get recognized by Tcl as string reps of doubles with [expr] without quoting. - login: "dgp"
- mimetype: "text/plain"
- title changed to: ""Inf" not understood in expr"
- username: "dgp"
- icomment:
Ticket change [6968397eb5] (rid 103244) by dkf on 2002-07-22 16:15:39:
- assignee changed to: "dkf"
- icomment:
Logged In: YES user_id=79902 % expr {inf + 1} syntax error in expression "inf + 1": variable references require preceding $ % expr {nan + 1} domain error: argument not in valid range % set i inf; expr {$i + 1} can't use floating-point value as operand of "+" % set n nan; expr {$n + 1} domain error: argument not in valid range % info patch 8.4b2 % parray tcl_platform tcl_platform(byteOrder) = bigEndian tcl_platform(machine) = sun4u tcl_platform(os) = SunOS tcl_platform(osVersion) = 5.8 tcl_platform(platform) = unix tcl_platform(user) = fellowsd tcl_platform(wordSize) = 4 - login: "dkf"
- mimetype: "text/plain"
- title changed to: "'Inf' not understood in expr"
- username: "dkf"
Ticket change [a114b9a105] (rid 109659) by dkf on 2002-07-22 17:04:58:
- closedate changed to: "2002-07-22T10:04:58"
- closer changed to: "dkf"
- resolution changed to: "Fixed"
- status changed to: "Closed"