According to the User guide, the “mod” operator returns the remainder of the division of two numbers as an integer.
I need to have the reminder with its decimals.
I found this procedure: mod(y,x) [in other languages] can be obtained as: y-x*Floor(y/x) which it works.
Is there an operator or a procedure I haven’t found that gives the same result?
Thank you
Nothing native to Xojo.
Thank you, I guess I’ll stick to that method.
You can also use
(y mod x)/x
which may be easier to understand the intent. YMMV
Thanks Tim, it seems easier
I’m not getting how (y mod x)/x will give the right answer. Using 5.4 mod 2 = 1. Divide it by 2 and you’ve got .5, where you’d want 1.4. Is that right?
The way I do it (when I want just one decimal digit), is to multiply the numbers by 10 and divide the result by 10:
(5.4 x 10) Mod (2 x 10) = 14
14 / 10 = 1.4
Result = (y10 Mod x10)/10
If you want 2 decimal digits, use 100 and so on.