floating point modulo in expr?
hi,
shouldn't it be possible to use % in expr more or less the same way
as in the % object - with floats?
thanks,
jan
Apologies if you're making an observation and not asking for a solution, but as it doesn't work, and possibly never will do because modulo arithmetic is for integers only, you can do this to get the remainder of a float division in expr:
[expr $f1 - ($f2 * int($f1 / $f2))]
Regards
Alex
Hey everyone! Years later, my C ignorance didn't know this, and It was great to see it, and a solution explained to me! So thank you for having this thread still on the site!
Hey, Jan.
the modulo work is integer-based. Grab the non-integer portion and process it separately, as my pal Alex suggests, and you'll be good to go!
Zeg tegen Jantine dat ik "hoi" heb gezegd! Misschien volgend jaar...
funny, i am always writing it the other way round: expr $f1-int($f1/$f2)*$f2
if i would be peter castine i could add that modulo is normally something different, and both, max and C, do it wrong. :)
Funny, I'll just throw out that I decided to use a different approach in my situation for brevity:
($f1*100/$f2) % 100 * 0.01
This gave a fixed decimal result. But of course, I will have the other implementation in a comment...I did a little reading on float vs int math, and more recent gpu's have a smaller benefit to int math over float. Also, I am using this in a jit.expr rather than an expr or vexpr.
All things to consider, and it leads me to a question which I might post elsewhere #mindDrifting
0.01ing things is often enough to "float" them.