Bugs item #1098051, was opened at 2005-01-07 10:14
Message generated for change (Comment added) made by andreas_kupries
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112883&aid=1098051&group_id=12883
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: math
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Andreas Kupries (andreas_kupries)
Assigned to: Arjen Markus (arjenmarkus)
Summary: bignum::rshift is wrong for negative inputs.
Initial Comment:
Test cases to consider:
[10:04] kbk Oh, by the way, >> is wrong as well.
[10:05] aku Are you talking about bignum::rshift ?
[10:05] kbk Uhm, yeah. -1>>1 is -1, not 0; -3>>1 is -2,
not -1.
[10:06] aku Well, rshift is not tested by the bignum
testsuite.
[10:06] kbk Well, I suppose that I've just proposed a
couple of tests, then.
[10:07] aku Yep
[10:08] aku I will cut&paste this into a bug report
And a solution, by Kevin:
[10:08] kbk Fixing that one is: A>>B = ~(~A>>B) =
-((-A-1)>>B)-1
Note: ~A is defined as (-A)-1 (Infinite precision
two-complement).
The general context is a talk on the chat about bignums
in Tcl (core-level), something Kevin is working on, and
for complete seamlessness he has to impl. all bitops,
i.e. &, |. ^. Through this we also looked at the tcllib
bignum code in this area. Especially as there is a RFE
pending for more bitops as well.
[10:11] aku We might have to look at the
set/clear/test-bit operators as well I guess.
[10:12] kbk Well, for tcllib's bignums, we don't have
to make them algebraically consistent with 2-s comp
ints, because they can't appear in [expr].
----------------------------------------------------------------------
>Comment By: Andreas Kupries (andreas_kupries)
Date: 2006-01-30 20:21
Message:
Logged In: YES
user_id=75003
Rely on the ordinary operations how ?
They do work correctly assuming that the Tcl integers are
limited-precision (32 or 64 bit). In 8.5 they are themselves
extended for bignums. ... That may mean that you can use 8.5
regular ops to determine what results the tests should
expect. Kevin might be able to help you with that.
----------------------------------------------------------------------
Comment By: Arjen Markus (arjenmarkus)
Date: 2006-01-30 05:34
Message:
Logged In: YES
user_id=400048
I ought to add the proposed tests (mind you: bit operations
are not my cup-of-tea - I will need some help on the
correct outcome or can I rely on the bit operations in Tcl
for ordinary integers?
----------------------------------------------------------------------
Comment By: Andreas Kupries (andreas_kupries)
Date: 2006-01-29 01:16
Message:
Logged In: YES
user_id=75003
Is this report still relevant ?
----------------------------------------------------------------------
Comment By: Arjen Markus (arjenmarkus)
Date: 2005-01-13 01:43
Message:
Logged In: YES
user_id=400048
I have asked Salvatore Sanfilippo, who wrote this package to
look into these problems
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112883&aid=1098051&group_id=12883
|