[Issue 9061] BigInt | BigInt, BigInt & int
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Nov 7 08:30:46 PST 2013
https://d.puremagic.com/issues/show_bug.cgi?id=9061
--- Comment #5 from bearophile_hugs at eml.cc 2013-11-07 08:30:43 PST ---
(In reply to comment #4)
> While working on this today, I noticed an unpleasant detail. What should be the
> result of this:
>
> import std.bigint: BigInt;
>
> void main() {
> BigInt a = "0xB16_B16_B16_B16_B16_B16_B16_B16_B16";
> BigInt b = 4;
> BigInt c = a & ~b; // Unset bit 3
> assert(c == BigInt("0xB16_B16_B16_B16_B16_B16_B16_B16_B12");
> }
>
> And if the comment is correct, then this is wrong:
>
> import std.bigint : BigInt;
>
> void main() {
> BigInt a = "0xB16_B16_B16_B16_B16_B16_B16_B16_B16";
> BigInt b = 4;
> BigInt c = a & b; // Separate bit 3
> assert(c == 4);
> }
>
> I would argue that the latter behavior is better, and a separate function may
> be required for the former.
>
> Also, how should ~b work, if at all?
This is what Python 2.6.5 answers to your questions:
>>> a = 0xB16B16B16B16B16B16B16B16B16
>>> b = 4
>>> c = a & ~b
>>> c == 0xB16B16B16B16B16B16B16B16B12
True
>>> a = 0xB16B16B16B16B16B16B16B16B16
>>> b = 4
>>> c = a & b
>>> c
4L
>>> ~b
-5
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list