in which the result of the modulo operation has the sign of the dividend (including C), unless the dividend is of an unsigned integer type. This is because, if the dividend is negative, the modulo will be negative, whereas will always be positive. For these languages, the equivalence x % 2n == x < 0 ? x | ~(2n - 1) : x & (2n - 1) has to be used instead, expressed using bitwise OR, NOT and AND operations. Optimizations for general constant-modulus operations also exist by calculating the division first using the constant-divisor optimization. Properties (identities) Some modulo operations can be factored or expanded similarly to other mathematical operations. This may be useful in cryptography proofs, such as the Diffie–Hellman key exchange. Some of these properties require that and are integers. Identity: . for all positive integer values of . If is a prime number which is not a divisor of , then , due to Fermat's little theorem. Inverse: . denotes the modular multiplicative inverse, which is defined if and only if and are relatively prime, which is the case when the left hand side is defined: . Distributive: . . Division (definition): , when the right hand side is defined (that is when and are coprime), and undefined otherwise. Inverse multiplication: . In programming languages In addition, many computer systems provide a functionality, which produces the quotient and the remainder at the same time. Examples include the x86 architecture's instruction, the C programming language's function, and Python's function. Generalizations Modulo with offset Sometimes it is useful for the result of modulo to lie not between 0 and , but between some number and . In that case, is called an offset. There does not seem to be a standard notation for this operation, so let us tentatively use . We thus have the following definition: just in case and . Clearly, the usual modulo operation corresponds to zero offset: . The operation of modulo with offset is related to the floor function as follows: (To see this, let . We first show that . It is in general true that for all integers ; thus, this is true also in the particular case when ; but that means that , which is what we wanted to prove. It remains to be shown that . Let and be the integers such that with (see Euclidean division). Then