POV-Ray : Newsgroups : povray.general : mod() returns negative result : Re: mod() returns negative result Server Time
1 Aug 2024 10:14:58 EDT (-0400)
  Re: mod() returns negative result  
From: John VanSickle
Date: 16 Nov 2005 18:14:14
Message: <437bbd46$1@news.povray.org>
Ard wrote:

> POV's mod(-3, 10) returns -3.  I don't have a problem with the
> documentation: mod() works as described, returning ((A/B)-int(A/B))*B where
> int(A) is not further from 0 than A on a number line.
> 
> However I do think that POV's mod() should behave like Perl's, and with
> common (I thought) practice, where mod(A,B) lies in the range [0,B) for all
> positive B.

In modulo arithmetic, numbers outside of the 0 to n-1 range simply 
aren't in the field.

It would be more precise to call it a remainder function.

Regards,
John


Post a reply to this message

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