NTRU Prime: more unary negations

Esse commit está contido em:
John M. Schanck 2020-09-01 17:15:01 -04:00 commit de Kris Kwiatkowski
commit 333248de03
3 arquivos alterados com 3 adições e 3 exclusões

Ver arquivo

@ -15,7 +15,7 @@
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}

Ver arquivo

@ -15,7 +15,7 @@
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}

Ver arquivo

@ -15,7 +15,7 @@
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}