0

Hi this is my cuda kernel

__global__ void calculate() {
 float a = 1008521344.0;
 float b = 3995.0;
 float c = 19228.0;
 float d = 0;
 d = a + b*c;
 printf("test result: %.6f\n", d);
}

I got the value from running this kernel:

test result: 1085337216.000000

But i expect the value to be: 1085337204

where is this mismatch from?

kingwales
  • 129
  • 8
  • limits of `float` resolution. Floating-point numbers larger than around 16 million may not have an exact representation in `float` format. According to my testing you get the same answer ending in 16 if you run that sequence in host code. – Robert Crovella Oct 17 '22 at 20:37

0 Answers0