Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2007-04-30
23:29 • Deleted ticket [1710132fff]: expr int(9...9) returns -1 ... Is this a bug?... artifact: f16eb8ffa9 user: afredd
23:28 • Closed ticket [1710132fff]. artifact: 17b3ecc135 user: afredd
15:35 • New ticket [1710132fff]. artifact: d750af0b42 user: afredd

[expr int(9...9)] returns -1 ... Is this a bug?

Deleted1710132fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 20 years ago
Descriptionplain2007-04-30 15:35:16
Consider,

% info pat
8.5a6
% expr int(9999999999999999999999999999999999999999999999)
-1

but

% info pat
8.4.14
% expr int(9999999999999999999999999999999999999999999999)
integer value too large to represent


Also get similar behaviour with wide().

Judging from the code the new behaviour should be
to return the result that is the bottom
sizeof(the-relevent-C-integer-type) bits of the
argument (ExprIntFunc), but the result is getting set
to -1. mp_mod_2d() looks a possible culprit.
afreddplain2007-04-30 23:28:40
Logged In: YES 
user_id=1386588
Originator: YES

Doh... ought to have tried some other input numbers!

I was only using long numbers of the form 99...9
and these happen to be be = N*(2**32) + (2**32 - 1)
ie. when int()'d they should be -1.
Adding another 9 to the test number is same as
multiply by 10 and add 9. Add (-1 * 10 + 9) == -1

Funny :-)
afredd Deleted ticket [1710132fff]. [History diff]2007-04-30 23:29:52
Log in (anonymous is fine) to add a comment.