POV-Ray : Newsgroups : povray.advanced-users : Negative division : Re: Negative division Server Time
29 Jul 2024 02:27:51 EDT (-0400)
  Re: Negative division  
From: ABX
Date: 10 Mar 2003 12:28:11
Message: <ophp6vc4tk3lmgeassae20t1qsq47ocqfh@4ax.com>
On Sun, 9 Mar 2003 12:45:27 -0000, "Andrew Coppin" <orp### [at] btinternetcom>
wrote:
> What do div() and mod() do in the case of negative numerator/denominator?

It does operations delivered by C++ libraries/compilers.

> The docs don't seem to speficy...

You have to look into standard libc libraries documentations used to compile
your binary. Quoting POV sources:

for regular SDL expressions:

          case DIV_TOKEN:
            Parse_Float_Param2(&Val,&Val2);
            Val=(DBL) ( (int)(Val/Val2) );
            break;

          case MOD_TOKEN:
            Parse_Float_Param2(&Val,&Val2);
            Val = fmod(Val,Val2);
            break;

for functions:

          Sys2 POVFPU_Sys2Table[] =
          {
             pow,            // 0
             atan2,          // 1
             fmod,           // 2
             math_div,       // 3
             NULL
          };

          SYS_MATH_RETURN math_div(SYS_MATH_PARAM i1, SYS_MATH_PARAM i2)
          {
            return (SYS_MATH_RETURN)((int)(i1/i2));
          }

How dividing in div() works you probably know
What fmod does you can check in online manuals like:
http://www.cplusplus.com/ref/cmath/fmod.html
http://www.gnu.org/manual/glibc-2.2.5/html_node/Remainder-Functions.html
http://www.delorie.com/djgpp/doc/libc-2.02/libc_294.html
http://www.digitalmars.com/rtl/math.html#fmod

ABX


Post a reply to this message

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