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) {...@@ -1271,6 +1271,12 @@ void bigint_and(BigInt *dest, const BigInt *op1, const BigInt *op2) {
1271}1271}
12721272
1273void bigint_xor(BigInt *dest, const BigInt *op1, const BigInt *op2) {1273void 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 }
1274 if (op1->is_negative || op2->is_negative) {1280 if (op1->is_negative || op2->is_negative) {
1275 // TODO this code path is untested1281 // TODO this code path is untested
1276 size_t big_bit_count = max(bigint_bits_needed(op1), bigint_bits_needed(op2));1282 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() {...@@ -369,3 +369,8 @@ fn test_f128() {
369fn should_not_be_zero(x: f128) {369fn should_not_be_zero(x: f128) {
370 assert(x != 0.0);370 assert(x != 0.0);
371}371}
372
373test "xor with zero" {
374 assert(0xFF ^ 0x00 == 0xFF);
375 comptime assert(0xFF ^ 0x00 == 0xFF);
376}