[ Team LiB ] Previous Section Next Section

64-Bit Support

Changes to several commands provide better support for 64-bit values, even on 32-bit platforms. (TIP #72) The changes implemented were designed to maximize backward compatibility.

64-Bit Arithmetic

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.

64-Bit Value Conversions

The format and scan commands now support the l modifier for use with integer-handling conversion specifiers (d, u, i, o, and x), which tells them to work with 64-bit values. The binary command gained new w and W specifiers for its format and scan subcommands, which operate on 64-bit wide values in a fashion analogous to the existing i and I specifiers (that is, smallest byte to largest, and largest byte to smallest, respectively).

64-Bit Filesystem Support

All Tcl commands interacting with the filesystem (file, glob, seek, and tell) work correctly for files larger than 2 GB.

Native Word Size Detection

The tcl_platform array contains a new tcl_platform(wordSize) element, which gives the native size of machine words on the host platform.

    [ Team LiB ] Previous Section Next Section