POV-Ray : Newsgroups : povray.newusers : rounding and logic functions : Re: rounding and logic functions Server Time
7 May 2024 11:00:32 EDT (-0400)
  Re: rounding and logic functions  
From: Bald Eagle
Date: 3 Aug 2013 11:10:01
Message: <web.51fd1cfc87475f8873fc9ebb0@news.povray.org>
I was doing a simple #if - #else - #end loop and trying to trigger an update
once every "hour".
#if ( Time1 = ceil ( Time1 ) )

> What's wrong with them?

They just seemed to operate opposite to how I expected, but it could just be
that I was tired and the problem was my brain, not the functions.  I'm going to
investigate further.  With coffee.  :)


Your cake analogy cleared that up immensely.  I now can "see" the process
clearly in my mind.  Thanks!

> > Is there no simple ROUND() function?  To round a number to Q decimal places?
>
> You can achieve a round-to-nearest-integer using ceil(X-0.5); You can
> achieve a round-to-Q-decimal-places by multiplying before and dividing
> after, such as in:
>
>      ceil( X*pow(10,Q) - 0.5 ) * pow(0.1,Q)

Right.  I guess I wanted truly simple and straightforward, not the "you can
write your own formula for doing what should only t5ake invoking an easily
remembered and commonly used command".
It's also rather frustrating to a noob when searching for "round", and there's
no cross-index for floor and ceil, terms which no one would ever think to search
for.


> simple - just perform two individual comparisons and apply the OR
> operator ("|"):
>
> #if ((x = a) | (x = b))

Oh.  Bald Eagle, meet the OR operator.  OR operator, Bald Eagle.  I'll let you
two get acquainted.

That would have been a helpful cross index as well.
I searched for OR, Boolean, comparators, if, logic, functions, ....   no OR.


Post a reply to this message

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