|
 |
On 10/11/2025 03:52, Kenneth wrote:
> In any case, POV-ray's 'mod' can obviously work with float values too...and
> fractions...at least when running in Windows. So IMO the docs are either
> outdated or too 'strict', and at least somewhat unclear.
Indeed, the definition given in the documentation is somewhat
restrictive or ambiguous at first glance.
Just as multiplication is a simple addition, division is a simple
subtraction.
Starting with any number (numerator), subtract the denominator as many
times as possible : that is, as long as the remainder is greater than
the denominator.
The “last” number is therefore the remainder. This is the number that
the modulo function returns.
Try this :
#declare a = 27.44;
#declare b = 7.97;
#while(a > b)
#declare r = a - b;
#debug concat("mod(",str(a,0,2),", ",str(b,0,2),") = ",str(r,0,2),"\n")
#declare a = r;
#end
Which gives :
mod(27.44, 7.97) = 19.47
mod(19.47, 7.97) = 11.50
mod(11.50, 7.97) = 3.53
...and 3.53 is of course equal to mod(27.44, 7.97)
--
kurtz le pirate
compagnie de la banquise
Post a reply to this message
|
 |