calc: 'MOD' in sheet vs. 'MOD' in macro - want to drive me crazy?
in a sheet: =mod(75,293;1)
results in 0,29300000000000 6', crazy enough i'm just working / playing around with the six,
but now, in basic macro: a = 75,293 mod 1
results in '0',
afaik it's not a wrong declaration of 'a' or a matter of punctuation,
a = 75.293 - int(75.293)
works fine and produces '0,293' ...
perplexed
b.
May be these articles give an explanantion of
.... 6
in the spreadsheet function:https://blog.reverberate.org/2014/09/what-every-computer-programmer-should.html
https://blog.reverberate.org/2016/02/06/floating-point-demystified-part2.html
@Opaque: i do know - something - about the float mysteries, in fact i'm just trying to construct a macro function to substitute 'MOD' which doesn't suffer from the fp-rounding issues, as a proof of concept that 'correct' decimal math is! possible with the tools we have also on systems which internally use binary-fp's
The thing is. It is not a rounding issue. It is an issue because no rounding based on heuristics occurs. In other words: Use
ROUND()
function, whenever you need rounded values (and you control what you want and you know what you do).And reagarding
a = 75.293 - int(75.293)
works fine and produces '0,293' ...: I cannot confirm this. Just created a user functionMYMOD
and the formula=MYMOD(75.293)
results (as expected) in:0.293000000000006
oh, we miss each other, the 'suffer from fp-rounding' does not refer to this question, but to the project where this question appeared, the =75,293-int(75,293) does not refer to this problem, but to the possible assumption that wrong punctuation is responsible for this problem,
the problem for this question is if mod of a fraction should result with fraction, or be rounded away, and that it's different between sheet and basic