POV-Ray : Newsgroups : povray.advanced-users : Stepped loop values and mod() : Re: Stepped loop values and mod() Server Time19 Jun 2024 16:08:23 EDT (-0400)
 Re: Stepped loop values and mod()
 From: Bald Eagle Date: 3 Aug 2018 08:35:01 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.5b644b9e3fc5936fc437ac910%40news.povray.org",
"headline": "Re: Stepped loop values and mod()",
"dateCreated": "2018-08-03T12:35:01+00:00",
"datePublished": "2018-08-03T12:35:01+00:00",
"author": {
"@type": "Person",
"name": "Bald Eagle"
}
}
clipka <ano### [at] anonymousorg> wrote:

> In the binary system typically used in computers, this imples that the
> problem arises whenever M is not a power of 2.

So, POV-Ray reinforces the patriarchal stranglehold that the Old Boy's Club  has
on implementing a non-binary system, eh?

> Note that 0.1 represents a /decimal fraction/, namely 1/10. Since 10 has
> 5 as one of its prime factors, which isn't a power of 2, the problem
> applies here.

I thought it was something like that - just wanted to be sure.

> In for loops, the problem can be avoided altogether by always using an
> integer loop variable, and from that "technical" loop variable compute
> an "effective" loop variable via multiplication or division, e.g.:
>
>     #for (I, 0, 1000, 1)
>         #local T = I * 0.1;
>         ....
>     #end

Well, this is interesting:
(a) it works - thanks!  :)

(b) my #debug output still shows a "remainder" in the 14th or 15th decimal place
- is that just an artifact showing up _after_ mod() is made happy?
```