I'm assuming that you're talking about 32-bit integer overflow, rather than floating-point overflow. If that's the case, then Tcl supports 64-bit integer arithmetic (even on 32-bit platforms) as of Tcl 8.4:
"The
expr command now supports 64-bit (wide integer) arithmetic. Integer constants unable to fit in a signed 32-bit value are treated as wide integers, unless they exceed the capacity of 64 bits, in which case they are treated as double-precision floating point values. The result of an arithmetic operation is a double if at least one of the operands is a double, a wide integer if at least one of the operands is a wide integer, and a normal integer otherwise.
"The
int() function always returns a non-wide integer (converting by dropping the high bits), and the new
wide() function always returns a wide integer (converting by sign-extending).
"The
incr command can increment variables containing 64-bit values correctly, but can accept only 32-bit values as amounts to increment by."
If you can't move up to Tcl 8.4, or if you're exceeding the capacity of 64-bit integers, then you'll need an extension like
mpexpr. Go to the Tcl'ers Wiki (
and check out the page "Mpexpr,"
for more information.
- Ken Jones, President, ken@avia-training.com
Avia Training and Consulting,
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax