The Tcl 'expr' command works with signed integers, whatever the
size of an int is on your platform. However, it is just a stream
of bits, so when you have your number, just do:
format %u -1
However, note that this number is really for viewing only, because
as soon as expr gets it again, it will be signed internally. Again
this likely isn't a problem as you can put the end result through
format again. Here is an example:
(tkcon) 49 % format %u -1
4294967295
(tkcon) 50 % expr {[format %u -1]-1}
-2
(tkcon) 51 % format %u [expr {[format %u -1]-1}]
4294967294
Note that Tcl 8.4 may be slightly different for some. It is adding
"wide integers" to the core, mostly to handle 64 bit file systems,
but also for calculations with large numbers. In 8.4, the above
command at 50 will actually return 4294967294 directly. This means
long longs are used when necessary (or int64 on Windows).
Jeff Hobbs The Tcl Guy
Senior Developer http://www.ActiveState.com/
Tcl Support and Productivity Solutions
JamesRanson wrote:
...
> 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.