Question

I want my java me program to run as efficiently as possible. my goal is to make a ray cast and want to know the best way to traverse voxels. I have heard that conversion and comparison of floating point numbers is very CPU intensive. So I figured why not add a certain distance to each rays x and y, truncate the remainder, and use those coordinates to then check an octree for a voxel. Basically, is there a better way of going about doing something like this for a java me program?

Truncating floating point numbers?

Was it helpful?

Solution

"Floating point math is slow" is old wisdom - however, it is also outdated wisdom. On modern desktop CPUs, floating point computations are fast, and there is little to gain on fixed-point computations.

Edit after having reread the question title: The approach you describe is perfectly viable, except that you need to multiply, not add to, each number. However, you should first write a small performance test program that checks whether the kind of computations you intend to do will actually benefit from fixed-point math on the hardware where you intend to run your program.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top