Re: Help calculating large modulus

From: Jeff Hobbs (jeffh_at_activestate.com)
Date: 12/08/03


Date: Mon, 08 Dec 2003 03:04:57 GMT

Helmut Giese wrote:
> On 7 Dec 2003 13:32:34 -0800, elf_ster@hotmail.com (Gordon) wrote:
>>I'm a newbiew trying to get the modulus of a 32-bit number.
>>
>>(0x123456abcdef)mod(999899)
>>
>>I expected to do: set mod [expr 0x123456abcdef%999899] but I receive
>>"integer value too large to represent".

> which OS? Which version of Tcl ?
>
> On my Win98 box running Tcl 8.4.5 I can enter any of
> expr 0x123456abcdef%999899
> expr 0x123456abcdef % 999899 (note the spaces)
> expr wide(0x123456abcdef) % 999899
> and get a result of 519634.

As Helmut points out, 8.4 is the answer. BTW, you aren't getting
the modulus of a 32-bit number - that would work in any version of
Tcl. You have a 48-bit number, and Tcl extended core support to
64-bit nums in 8.4.

-- 
     Jeff Hobbs, The Tcl Guy
     http://www.ActiveState.com/, a division of Sophos