POV-Ray : Newsgroups : povray.programming : unnecessary int to float to int conversion : unnecessary int to float to int conversion Server Time
8 Jul 2024 19:37:52 EDT (-0400)
  unnecessary int to float to int conversion  
From: ABX
Date: 27 Jan 2003 11:33:29
Message: <o5na3v0s4oa527db5bp2229mqkaolse3p4@4ax.com>
In files bbox.cpp and bsphere.cpp there is unnecessary conversion from int to
float for multiplication value by 1.5 and then it is converted back for
assignement to the same int variable. I'm talking about:

bbox.cpp:
  maxfinitecount = 1.5 * maxfinitecount;

bsphere.cpp:
  maxelements = 1.5 * maxelements;

It is possible that some C++ compilers perform such operations completly on
ints but I doubt it is part of C++ standard or component of being not
outdated. The same written as

bbox.cpp:
  maxfinitecount += maxfinitecount / 2;

bsphere.cpp:
  maxelements += maxelements / 2;

where '/2' on ints is often calculated using bits operations seems useful.
I'm reposting it here becouse it seems not ordinary 'warning free' issue.

ABX


Post a reply to this message

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