
Bug with mod(x,y) function?

Sandbo
With Igor 6.37,
I was trying to use the mod function but it turns out funny, so I checked it step by step and found this:
•print (mod(3.8e-6*1.2*1e9,2*8)) 16
where
print 3.8e-6*1.2*1e9/(2*8) 285
Checking on Wolfram, the mod does give zero.
https://www.wolframalpha.com/input/?i=(mod(3.8e-6*1.2*1e9,2*8))
Am I missing something?
PS: Just tested in Igor 7.0.8, the same happens.
April 3, 2018 at 02:10 pm - Permalink
Thanks for the idea, sounds like a precision issue.
In my case I can modify it to have 3.8, that should solve it for now.
Update: Not really, and I found another problem.
The above were a proc for a panel setVariable action entry.
1. If I type in a number 3.8e-5, the mod() returns zero and it works.
2. If I scroll using mouse from 3.7e-5 to 3.8e-5 (incre is 1e-6), the mod() returns something funny and cause problem.
April 3, 2018 at 02:32 pm - Permalink
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
April 3, 2018 at 02:38 pm - Permalink
Thanks a lot, this has solved it completely (even with scrolling).
April 3, 2018 at 02:51 pm - Permalink