Intrinsic-58 Mod |
Top Previous Next |
58: real:= Mod(real, real);
This intrinsic computes the modulo function. This is the real counterpart to the Rem intrinsic (2). Mod(A, B) is defined as A modulo B, which is defined as A - Int(A/B) * B. Where Int(A/B) extracts the largest integer <= Abs(A/B) and attaches the sign of A/B (i.e. it truncates toward zero). For example:
X:= Mod(10.2, 3.0); \X:= 1.2 X:= Mod(-10.2, 3.0); \X:= -1.2 X:= Mod(123.456, 1.0);\Get the fractional part (0.456) X:= Mod(7.6, 2.5); \X:= 0.1
|