title: Java raytracing float vs double
body: <p>Last semester we had to develop a raytracer for a course at school. School being done, I tried to fiddle a bit with it. </p>
  
  <p>I wanted to see what would change if I changed all floating point calculations from double to float (all calculations being done with doubles). So I changed every variable to type float, and simply cast each double returned from the Math methods to float. Testing my raytracer on a couple of scenes showed a pretty decent performance increase.</p>
  
  <p>Searching around the web I found various reasons why float could be faster, but also some saying that double could be as fast, or even faster in a 64-bit environment. The thing is, I am running in a 64-bit environment and JVM. What would be the reason for this increased performance?</p>
  
  <p>Now, I'm reading the PBRT book and planning to rewrite a raytracer from scratch following this. Would choosing float for all floating point calculations pose any problems? I didn't notice any during my tests, but perhaps for certain scenes the lower precision might (intersection testing seems like where it could pose a possible problem)? Or perhaps a tradeoff, like using double for the critical tests and float for less critical calculations? I would have to use an other Math library to get rid of the casting, would I be going the float way.</p>