Advertisement

float or int

Started by February 26, 2000 11:00 AM
4 comments, last by 1c4i4 24 years, 6 months ago
Hy, I was wondering, do I have to use floats or ints for my objects coordinates. Float will have more presision but and is faster, except for the rasterization. int will be faster when rasterizing. Which performance loss will be most important and should I ignore ... thanx, 1c4i4
if you''re that worried about speed, use a 32 bit int(assuming you''re on a 32 bit machine).. or if you really need a fractional value, use fixed point
Advertisement
whats your target?
I''m guessing some sort of pentium... floats are faster than ints in a lot of places...
ints are fast if its an older system (486,386,ect).

rast will be the biggest performace hit... alot more calculating than movement and the like...

also is it 3d or 2d? I personaly use ints for 2d and floats for 3d

Great Milenko

Words Of Wisdom:
"Never Stick A Pretzel In Your Butt It Might Break Off In There."


http://www.crosswinds.net/~milenko
http://www.crosswinds.net/~pirotech

The Great Milenko"Don't stick a pretzel up your ass, it might get stuck in there.""Computer Programming is findding the right wrench to hammer in the correct screw."
thanx huys,

I am speeking 2D right now. But thanx for the info to use floats when programming 3D stuff. Does anyone of you know how big the performance loss is when converting floats to ints on Pentium machines.

1c4i4
in my opinion, just used fixed point
The performance loss is a big issue when converting floats to ints on pentiums... however there are workarounds.

If you can deal with only using 23 bits of the float for the int instead of all 32, you can just add
8388608.0f to the and mask off the upper 9 bits. this will just about double the speed of using a standard type cast.

This topic is closed to new replies.

Advertisement