Fixes #215
MSVC doesn't like when we expand unsigned integers after a bitwise
negation. A fair distaste, except this time it's wrong. Writing
`(~x & 0xffffffff)` instead of just `~x` shows MSVC the error of its ways.
Also made a potentially lossy conversion to `int` explicit (and
explained in a comment why there is no actual loss).
// (-L == ~L + 1)
u64 carry = 1;
FOR (i, 0, 8) {
- carry += (u64)x[i] + ~L[i];
+ carry += (u64)x[i] + (~L[i] & 0xffffffff);
carry >>= 32;
}
- return carry;
+ return (int)carry; // carry is either 0 or 1
}
// Final reduction modulo L, by conditionally removing L.
// xr = x - xr
u64 carry = 1;
FOR (i, 0, 8) {
- carry += (u64)x[i] + ~xr[i];
+ carry += (u64)x[i] + (~xr[i] & 0xffffffff);
xr[i] = (u32)carry;
carry >>= 32;
}