POV-Ray : Newsgroups : povray.general : access object attributes : Re: access object attributes Server Time
29 Jul 2024 08:19:49 EDT (-0400)
  Re: access object attributes  
From: Le Forgeron
Date: 17 May 2013 09:42:02
Message: <519633aa@news.povray.org>
Le 17/05/2013 12:31, Stephen a écrit :
> And why multiply by a half instead of dividing by two? Is that more
> computer/CPU friendly?

It might.

If the compiler/interpreter does not catch that the operation is easy to
perform with a single decrement of exponent (in case of IEEE-754 float)
or a single bit shift (in case of integer), the used assembly code is to
use the multiply opcode, instead of the divide opcode.

Division at opcode-level is far more cycles-hungry than a
multiplication. (especially with float format, but prediction on current
CPUs is dependent on too many variables to assert that without actual
benchmark)

Now, beware of premature optimisation.


It might also be just a style of programming (*0.5) to keep the equation
on a single text line. (whereas the /2 would need a 2 lines on
graphically accurate display)


Post a reply to this message

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