When i have used numbers that are bigger i had to make tcl think it was a
float and put number.0 for it to do what i wanted
Darren Ferguson
On Mon, 25 Feb 2002 [EMAIL PROTECTED] wrote:
> I am working on a back-end logging system and am having a bit of difficulty
> with a number conversion. The resource that provides the IP address to log
> can only give it in Long format. I have come up with a function to convert
> the Long IP into Dotted Quad format, but the first division returns a
> negative value whenever the Long IP provided is greater than 2147483647. Can
> anyone help figure out why expr will not accept any values bigger than that,
> and what my options are? I have looked through the AOLServer functions to see
> if there was anything built-in that would work but nothing caught my eye.
>
> Thanks!
>
>
>
> proc dotted_ip_from_long { long_ip } {
>
> set n 1
> set ip_parts [list]
>
> while { $n < 5 } {
>
> set denom [expr int(pow(256,(4 - $n)))]
> set ip_part [expr int(floor($long_ip / $denom ))]
> set long_ip [expr $long_ip % $denom ]
> lappend ip_parts $ip_part
> incr n
> }
>
> return [join $ip_parts "."]
>
> }
>