(12C) Modulo (the remainder after division )
|
01-09-2018, 09:32 AM
(This post was last modified: 01-09-2018 09:45 AM by Dieter.)
Post: #2
|
|||
|
|||
RE: (12C) Modulo (the remainder after division )
(01-09-2018 06:03 AM)Gamo Wrote: The modulo operation finds the remainder after division of one number by another. There is more than you see in FIX 2. ;-) 7 mod 3 => 0,99999999 20 mod 7 => 5,999999999 200 mod 9 => 1,999999980 1E+9 mod 6 => 4,2 Or take you own examples: 91596 mod 123 => 82,99999640 456654 mod 104 => 93,99998400 98765 mod 43210 => 12344,99999 You could add 0,4 + INTG to round the results to an integer which would help in most cases. But this limits the output to integers so that 123 mod 2,5 = 0,5 cannot be calculated. And in a way this also is like cheating. ;-) As already noted, using b*frac(a/b) is not a good idea at all as it causes the shown roundoff errors. A better method is a – b*int(a/b). However, this requires some more steps if you want to preserve the stack: Code: 01 X<>Y This calculates all above examples correctly. All these methods are limited by cases where due to limited precision a/b is returned as an integer although it actually is not. Example: With 10-digit precision 8E+9 / 3 = 2666666667 so that the modulus is returned as 0 (frac method) or –1 (int method) instead of 2. Dieter |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(12C) Modulo (the remainder after division ) - Gamo - 01-09-2018, 06:03 AM
RE: (12C) Modulo (the remainder after division ) - Dieter - 01-09-2018 09:32 AM
RE: (12C) Modulo (the remainder after division ) - Gamo - 01-10-2018, 06:44 AM
RE: (12C) Modulo (the remainder after division ) - Gamo - 02-15-2018, 05:15 AM
RE: (12C) Modulo (the remainder after division ) - Gamo - 12-05-2019, 12:03 PM
RE: (12C) Modulo (the remainder after division ) - Joe Horn - 12-05-2019, 12:36 PM
|
User(s) browsing this thread: 2 Guest(s)