Floating point arithmetic

Since my GPU card does not support double precision, I have to use floating point instead of double. Then I encounter the following issues!

  1. A floating point type variable’s values become integers. This variable is the result of some math calculations. I don’t understand why so because it was declared and initialized to be float point. Anything I am not aware of about cuda? Is there any way to specify the precision?

  2. This is a general question. What’s the best way to rewrite the programs from c++ to cuda in which c++ double variables need to be converted into float point type? The straight forward way is to simply re-declare and re-initialize them from double to float point. But this caused above problem for me. any suggestions?

plz help and thanks!

Can you post some sample code? FP values spontaneously becoming integers sounds rather strange.

Thanks YDD! The code is large and I tried to narrow it down to a more specific question or code. But I couldn’t identify it yet.

The 7 significant digits for floating point might not be accurate enough for my calculation.