[Issue 9061] BigInt | BigInt, BigInt & int

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 7 08:10:11 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=9061


Simen Kjaeraas <simen.kjaras at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras at gmail.com


--- Comment #4 from Simen Kjaeraas <simen.kjaras at gmail.com> 2013-11-07 08:10:01 PST ---
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?

-- 
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