|
From: Donald G P. <dg...@ni...> - 2009-02-11 22:32:22
|
Daniel A. Steffen wrote:
> On Wed, Feb 11, 2009 at 22:37, Daniel A. Steffen
> <da...@ca...> wrote:
>> sure, my point was that [string is double] accepts all bignums,
>> including those that cannot fit into a C double without loss of
>> precision, or even those bigger than DBL_MAX...
>
> leading to things like this:
>
> % set x [expr {10**400}]
> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
> % string is double $x
> 1
> % expr {double($x)}
> Inf
>
> from the manpage text, I would not have expected an overflowing double
> to be acceptable:
>
> double Any of the valid forms for a double in Tcl, with
> optional surrounding whitespace. In case of
> under/overflow in the value, 0 is returned and the
> varname will contain -1.
Looks like an overlooked doc update.
From TIP 249, "Incompatibillities":
Third, Tcl_GetDoubleFromObj will be both more and less permissive than
before. It will no longer accept constants with a leading zero and no
decimal point or 'E' that are invalid octal numbers. On the other hand,
it will accept constants that are too large to fit in a Tcl_WideInt;
somewhat surprisingly, string repeat 9 50 cannot today be interpreted as
a double. string is double will follow Tcl_GetDoubleFromObj in what it
considers acceptable. Any string that is accepted as either an integer
or a double by expr will be accepted in Tcl_GetDoubleFromObj, and only
those strings will be accepted.
--
| Don Porter Mathematical and Computational Sciences Division |
| don...@ni... Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|
|