authorgravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-01-17 14:00:27+01:00
committergravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-01-17 14:00:27+01:00
logdb0fc32ab2d5277655a87200be8f602473ed30d2
treedd69bb34da92f00ff0b76bd638113188c0327cfc
parent1eda7e0fde88ac06eaf595f74157d1e6214c1b3d

fixed xor with zero


2 files changed, 11 insertions(+), 0 deletions(-)

src/bigint.cpp+6
......@@ -1271,6 +1271,12 @@ void bigint_and(BigInt *dest, const BigInt *op1, const BigInt *op2) {
12711271}
12721272
12731273void bigint_xor(BigInt *dest, const BigInt *op1, const BigInt *op2) {
1274 if (op1->digit_count == 0) {
1275 return bigint_init_bigint(dest, op2);
1276 }
1277 if (op2->digit_count == 0) {
1278 return bigint_init_bigint(dest, op1);
1279 }
12741280 if (op1->is_negative || op2->is_negative) {
12751281 // TODO this code path is untested
12761282 size_t big_bit_count = max(bigint_bits_needed(op1), bigint_bits_needed(op2));
test/cases/math.zig+5
......@@ -369,3 +369,8 @@ fn test_f128() {
369369fn should_not_be_zero(x: f128) {
370370 assert(x != 0.0);
371371}
372
373test "xor with zero" {
374 assert(0xFF ^ 0x00 == 0xFF);
375 comptime assert(0xFF ^ 0x00 == 0xFF);
376}