isOdd function

bool isOdd(
  1. BigInt num,
  2. BigInt modulo
)

Check if a BigInt number is odd with respect to a given modulo.

This function determines whether a BigInt 'num' is an odd number when computed within the modular arithmetic defined by 'modulo'. It calculates the remainder of 'num' when divided by 'modulo' and checks if the least significant bit is set to 1 (i.e., it's an odd number).

Parameters: num (BigInt): The number to be checked for oddness. modulo (BigInt): The modulus used for the modular arithmetic.

Returns: bool: 'true' if 'num' is an odd number within the given modulo, 'false' otherwise.

Implementation

bool isOdd(BigInt num, BigInt modulo) {
  return (positiveMod(num, modulo) & BigInt.one) == BigInt.one;
}