% format %x [expr 0x5ade3412ab]
de3412ab
% format %10x [expr 0x5ade3412ab]
de3412ab
Why doesn't [format] return the two leading digits "5a"?
I'm probably overlooking something, but can't see what.
Any help greatly appreciated,
Erik
--
leunissen@ nl | Merge the left part of these two lines into one,
e. hccnet. | respecting a character's position in a line.
format %i [expr 0x5ade3412ab]
-567012693
seems that you are out of range of hexa values regarding internal
registering, try with smaller figures
> format %i [expr 0x5ade3412ab]
>
> -567012693
>
> seems that you are out of range of hexa values regarding internal
> registering, try with smaller figures
Right. Thanks for pointing this out.
% format %x [expr 0x5ade3412ab]
integer value too large to represent
% format %x [expr wide(0x5ade3412ab) ]
integer value too large to represent
% format %lx [expr wide(0x5ade3412ab) ]
5ade3412ab
% format %x 0x5ade3412ab
integer value too large to represent
% format %lx 0x5ade3412ab
5ade3412ab
%
uwe
>Consider:
>
>% format %x [expr 0x5ade3412ab]
>de3412ab
>% format %10x [expr 0x5ade3412ab]
> de3412ab
Hi Eric,
seems like [format] needs a special format for wide integers. Try
format %lx [expr 0x5ade3412ab]
(this is a lower case L) - works for me on this old Tcl 8.4.13 machine
(Windows).
HTH
Helmut Giese
Do you have any idea why you get this helpful error message, and I just
get a plain wrong result?
Do we have different platforms/configurations?
Here's mine:
% format %x [expr 0x5ade3412ab]
de3412ab
% parray tcl_platform
tcl_platform(byteOrder) = littleEndian
tcl_platform(machine) = i686
tcl_platform(os) = Linux
tcl_platform(osVersion) = 2.6.18.8-0.9-default
tcl_platform(platform) = unix
tcl_platform(user) = erik
tcl_platform(wordSize) = 4
<snip>
> % format %lx 0x5ade3412ab
> 5ade3412ab
Thanks for pointing out this useful %lx conversion specifier.
Erik.
> %
> uwe
and
% info patch
8.4.18
Erik
Works for me too (Linux). Thanks,
Erik.
> HTH
> Helmut Giese
uwe
Well, that would suggest that something relevant changed in between
8.4.6 and 8.4.18.
Hmm ... well, be that so. I won't pursue this further.
Erik
> seems like [format] needs a special format for wide integers. Try
> format %lx [expr 0x5ade3412ab]
[format] has become a complete mess in Tcl today!
With multiple versions of integer representation
(normal, wide, unlimited; varying by platform)
plus automatic conversion between them, the fixed
size format specifiers are a broken relic from the
past. They require knowledge of a value's special
representation, when that is supposed to be hidden.
Unfortunately, in the beginning, [format] was copied
too blindly from C, but it didn't seem so bad in
those days -- the fixed-size implication of %x and %d
could be viewed as an irrelevant curiosity that had
no effect in Tcl. Now that Tcl has various sized of
integers, entirely different from the system in C,
the carry-over of format specifiers is terrible.
It is a painful hangover.
It seems that recently the meaning of the size
specifiers has changed from a requirement to a
conversion request. This may seem better than
getting type-errors in a typeless language, but
has the bad effect of entrenching and legitimizing
the use of these size-specific tags for type-
conversion. Whereas I would like to have the
simplest forms (%x, %d) work, without conversion,
on all sizes of internal integer.
The question is, would it be feasible to change the
meaning of the format specifiers to drop the size
requirement? Another prefix would have to be introduced
to retain the current behavior for conversion to
regular int.
Donald Arseneau as...@triumf.ca