POV-Ray : Newsgroups : povray.beta-test : Doc Error for mod? : Re: Doc Error for mod? Server Time
30 Jul 2024 10:15:34 EDT (-0400)
  Re: Doc Error for mod?  
From: Bob H 
Date: 23 Nov 2001 20:25:59
Message: <3bfef727@news.povray.org>

news:3BFE5E76.B3090531@atosorigin.com...
> "Bob H." wrote:
> > I see, but maybe you meant int(-2.5) would be -2 but I'd expect -2.8 to
> > become -3.  I only meant from 0.5, 1.5, 3.5, etc. would go toward 0.
Not
> > so?
>
> No.
> int stand for "integer part". So int(2.99999999) is still 2, even if
> it is dam close to 3.
> (Ok, 2. and an infinity of 9 is really 3, but computer have a problem
> with handling infinity that always I surprise me :-).
>
> You're thinking of the 'nearest integer' rounding, which can be done with
> int() too:  near(a) = int(a+0.5)
> (And still, some may want to round x.5 toward x rather than x+1,
> so it can still provide more discussion about using int or floor or ceil
>  [because of the different rounding direction for positive/negative]).

Okay, got it.  Enough of my blindly thinking int() was rounding up and down
based on which side of halfway between whole numbers then.  Thanks for
clearing that up for me.  One of those things I get stuck in my mind some
way and never question (unless problem arises).

Very good point about negatives being opposite direction, sort of, for
rounding; or toward zero like the doc says.

Bob H.


Post a reply to this message

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