POV-Ray : Newsgroups : povray.newusers : What does the 'mod' operator do? : Re: What does the 'mod' operator do? Server Time
11 Nov 2025 19:10:36 EST (-0500)
  Re: What does the 'mod' operator do?  
From: Kenneth
Date: 11 Nov 2025 17:00:00
Message: <web.6913b0d01bdd4431e83955656e066e29@news.povray.org>
kurtz le pirate <kur### [at] freefr> wrote:
>

> 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)
>

That's a clever little demonstration; I'm going to keep it for reference.
Thanks!


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.