|
2015-01-26
| ||
| 20:27 | • Closed ticket [3600057fff]: string is double "0x5" bug? plus 4 o... artifact: 3968e0f456 user: dgp | |
|
2013-09-27
| ||
| 10:42 | • Ticket [3600057fff]: 3 changes artifact: 0039c85892 user: dkf | |
|
2013-09-09
| ||
| 13:07 | • Pending ticket [3600057fff]. artifact: 84cb5293c4 user: dgp | |
| 12:58 | • Ticket [3600057fff]: 3 changes artifact: d42cbfc743 user: dgp | |
|
2013-09-08
| ||
| 23:43 | • Open ticket [3600057fff]. artifact: d881ee2f47 user: dkf | |
| 15:38 | • Ticket [3600057fff]: 5 changes artifact: 36694f38ee user: dgp | |
| 14:59 | *BACKPORT* [3600057]: Filled out missing parts of implementation of [string is double]. DGP - I'm... closed check-in: 2759df9850 user: dkf tags: bug-3600057-85 | |
| 14:50 | • Closed ticket [3600057fff]: string is double "0x5" bug? plus 7 o... artifact: d8158971ca user: dkf | |
| 14:48 | [3600057]: Filled out missing parts of implementation of [string is double]. DGP - I'm pretty sur... check-in: e81ce48725 user: dkf tags: bug-3600057 | |
| 14:09 | • Ticket [3600057fff] string is double "0x5" bug? status still Ope... artifact: 0db9937ff6 user: dkf | |
|
2013-09-05
| ||
| 08:46 | • Ticket [3600057fff]: 5 changes artifact: b7453cd247 user: dkf | |
|
2013-08-25
| ||
| 01:21 | • Ticket [3600057fff]: 6 changes artifact: f84be9701e user: dkf | |
|
2013-01-09
| ||
| 08:42 | • New ticket [3600057fff]. artifact: 9c22ff357e user: zoltan3 | |
[string is double "0x5"] bug?
I suppose, "0x5" cannot be a valid double, but it is accepted by "string is double".
% string is double "0x5"
1
But "lsearch" does not like it:
% lsearch -exact -real {0x5 2} 2
expected floating-point number but got "0x5"
("-real" means practically "-double"?)
Confirmed on 8.4 through 8.6, and this is definitely “unexpected”.
Ugh, the source contains the dreaded comment:
/* TODO */The functionality is outright missing.
That should be all fixed now, assuming that I've not made any silly errors. (I've added a fair few tests.)
Whoa! Whoa! Whoa! What's this? [string is double] is the script form of Tcl_GetDoubleFromObj(). Why are you narrowing its domain? Without discussion? The /* TODO */ comment is troubling yes, but with no indication what the one writing it thought still needed to be done, I'm not seeing the case for this. (And on the eve of a (patch!) release, coincident with attempts to prep for the conference, it's quite disturbing to me.)
In that case you take responsibility for getting it in. Assigned to you; if you assign back to me, I'll just commit the code to the main branch.
The issue is exactly that the code is not the same as Tcl_GetDoubleFromObj in that it allows “0x5” and “0o5” through despite these not being allowed in a real call to that function (which is what lsearch -real and lsort -real use internally). There is also (pre-patch) no test case that checks whether the domains of what is accepted and what rejected is reasonable in these edge cases.
The one downside is that string is double 0x5 returned 1 in 8.4 too. I'm guessing that that was always an oversight.
[string is double 0x5] == 1 is intended correct behavior.
Tcl_GetDoubleFromObj() should also succeed on "0x5" input.
In a brief round of testing that's what I see happening.
I have not been able to reproduce the ticket's claim
about
lsearch -exact -real {0x5 2} 2
raising an error.
I'll probe a bit more, but this is looking like
an Invalid ticket. If the OP is reading and can
add info about the Tcl release or other platform
or environment details where we might reproduce the
[lsearch] error, that could help.
The -real option for [lsearch] arrived in Tcl 8.4:
% info patch
8.4.0
% lsearch -exact -real {0x5 2} 2
1
(Combining -exact and -real is strange. but there it is)
The ticket claims about [lsearch] just are not correct
as far as I can tell.
The consistent rule implemented by Tcl is that all
integers are doubles. That is, the double "equivalent"
can be determined and used. This is in the sense of
[string is double] as well as Tcl_GetDoubleFromObj().
("equivalent" can be rather loosely interpreted. All large
enough bignum integers are equivalent to the double value "Inf")