Artifacts Associated With Ticket 1228275fffffffffffffffffffffffffffffffff
Ticket change [ac7b556454] (rid 101299) by matzek on 2005-06-27 13:55:26:
- assignee initialized to: "dkf"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Hi *, although I haven't found much documentation about this [expr] behavior, Welch et al. are writing: "The result of an arithmetic operation is [...] a wide integer if at least one of the operands is a wide integer, and a normal integer otherwise." And the manual of [expr] says: "wide(arg): Converts arg to an integer value at least 64-bits wide (by sign-extension if arg is a 32-bit number) if it is not one already." I now have two values, both fitting into a signed integer, which would need a wide integer when summed up. But I am somehow unable to get the right result: $ tcl-8.4.9/bin/tclsh8.4 % expr {(1<<31)+1} -2147483647 % expr {(1<<31)+wide(1)} -2147483647 % expr {wide(1<<31)+1} -2147483647 % expr {wide((1<<31))+1} -2147483647 % expr {wide((1<<31)+1)} -2147483647 On a 64bit system and compiled with --enable-64bit, I get the right result, right from the start: $ tcl-8.4.9/bin/tclsh8.4 % expr {(1<<31)+1} 2147483649 -- Matthias Kraft - foundin initialized to: "obsolete: 8.4.9"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "matzek"
- subsystem initialized to: "16. Commands A-H"
- title initialized to:
[expr] cannot cope with wideInt results on 32bit UNIX
- type initialized to: "Bug"
Ticket change [166b6dbf97] (rid 124714) by dkf on 2005-06-27 21:03:47:
- icomment:
Logged In: YES user_id=79902 The problem is that it is the << operation that is doing the wrong thing with the signs, and not the operations around it. On a 32-bit system: % expr (wide(1)<<31)+1 2147483649
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [49122ebd77] (rid 100005) by matzek on 2005-06-27 21:13:28:
- icomment:
Logged In: YES user_id=330806 Oh, yes ... well that solves my problem, feel free to close then.
- login: "matzek"
- mimetype: "text/plain"
- username: "matzek"
- icomment:
Ticket change [8a50da5e85] (rid 127373) by mdejong on 2005-06-30 04:14:14:
- icomment:
Logged In: YES user_id=90858 I think this is what you meant to do. 1<<31 is a negative number. % expr {(1<<31)-1} 2147483647 % expr {wide(1<<31)-1} -2147483649 - login: "mdejong"
- mimetype: "text/plain"
- username: "mdejong"
- icomment:
Ticket change [6d49dab446] (rid 128668) by mdejong on 2005-08-24 01:37:16:
- closedate changed to: "2005-08-23T18:37:16"
- closer changed to: "mdejong"
- resolution changed to: "Invalid"
- status changed to: "Closed"