DIFFERENCES BETWEEN DIVISION IN HOST AND DVCE CODE

Hello!
If I do in the host code the next division with these two floats: 0.6 / 0.00001. Its result is 6000, naturally. But if I do the same operation in the device code, the result is 5999.9958.
It makes me a great colision in my program. What it’s the cause of these differents results in a simple division? What can I do to solve this problem?

I have another question: which are the functions in cuda to round a float to an int?

And I have a finally question: May I copy an array of float of 5.000.000 of positions from host to device?? In what way I should copy these array? Because I need it all in device code to process it.

I need a answer, my FPC depends on it jeje. Thanks!

5 million floats are only around 20 MB, so the size is no problem. You just do a cudaMemcpy, simple :magic:

You should read up fixed point issues.

I put these numbers in fixed point for clarity for all, but both of them are floats, and so it seems that cuda have a little error in divisions that it’s hard to solve, itsn’t it?

check the accuracies in the Programming Guide. Also the CPU uses 80 bits precision unless you explicitly tell it not to, using floats is not enough.