Float vs double?

Dear everyone

I prefer double precision in my usual programming
However, Vulkan looks prefering float precision

So may I ask
May I just use double precision when I define my own classes in Vulkan programming
Or is it better for me to use float precision here?

(For examples, calculating positions, rotations, velocities, light amount, distances or matrices multiplications etc)

I will really appreciate if you advise me with this issue

Thank you

That’s up for you to decide. Though why would you store double, if you later downcast it to single anyway? Makes only sense if the math on it is particularly evil.

I mean, depends how many numbers. Nobody in the end cares if you store your random 42 floats as double. But it adds up if you have like millions.

On the GPU it is another matter. GPUs are devices that are made for single precission float ops. Double ops may have like 5x slower throughput (depending on architecture).

1 Like

Dear krOoze:

Thank you so much for your detailed advise and kindness

For example, in simulation, double precision is better (when fast performance is not required)

However, as you said, float ops are much faster in GPU,
I need to consider this.

(At now, I don’t focus on game programming)

I understand now, so see you again and please take care

Best,

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.