Commit db0fc32ab2
Changed files (2)
src
test
cases
src/bigint.cpp
@@ -1271,6 +1271,12 @@ void bigint_and(BigInt *dest, const BigInt *op1, const BigInt *op2) {
}
void bigint_xor(BigInt *dest, const BigInt *op1, const BigInt *op2) {
+ if (op1->digit_count == 0) {
+ return bigint_init_bigint(dest, op2);
+ }
+ if (op2->digit_count == 0) {
+ return bigint_init_bigint(dest, op1);
+ }
if (op1->is_negative || op2->is_negative) {
// TODO this code path is untested
size_t big_bit_count = max(bigint_bits_needed(op1), bigint_bits_needed(op2));
test/cases/math.zig
@@ -369,3 +369,8 @@ fn test_f128() {
fn should_not_be_zero(x: f128) {
assert(x != 0.0);
}
+
+test "xor with zero" {
+ assert(0xFF ^ 0x00 == 0xFF);
+ comptime assert(0xFF ^ 0x00 == 0xFF);
+}