multiplication in kernel gdb question

My kernel is below. When I examine the operation in line 30 with cuda-gdb I get x = 0 even though delfx = 0.19728535460436475 and threadIdx.x = 1
The cuda-gdb session follows the code.

I haven’t been doing this long so please excuse me if this is obvious.

12 global void genOTFc(double * dOTFc, double * dOTF, double delfx, double delfy, double delfz, double mx, double ang)
13 {
14 double squareroot(double x);
15 double tmpOTF1;
16 double tmpOTF2;
17 double angc,r;
18 double re, im;
19 long x, y, z;
20 int tid = threadIdx.x + blockIdx.x * blockDim.x + gridDim.x * blockIdx.y * blockDim.x;
21 if ( blockIdx.y < gridDim.y/2L +1L)
22 {
23 z = delfz * blockIdx.y;
24 }
25 else {
26 z = delfz * (gridDim.y - blockIdx.y);
27 }
28 if ( blockIdx.x < gridDim.x/2L +1L)
29 {
30 y = delfy * blockIdx.x;
31 }
32 else {
33 y = delfy * (gridDim.x - blockIdx.x);
34 }
35
36
37 x = delfx * (double) threadIdx.x;
38 r = squareroot(x
x + y
y);
39 angc = atan(r/z);
40 tmpOTF1 = dOTF + 2tid;
41 tmpOTF2 = dOTF + 2
tid + 1;
42 re = *tmpOTF1;
43 im = tmpOTF2;
44 double OTFctmp = dOTFc + 2tid;
45 OTFctmp++ = angc < ang ? sqrt(mx - rere - im
im) : 0.0;
46 *OTFctmp = 0;
47
48 }

(cuda-gdb) n
37 x = delfx * (double) threadIdx.x;
(cuda-gdb) p delfx
$5 = 0.19728535460436475
(cuda-gdb) p threadIdx.x
$6 = 1
(cuda-gdb) p (double) threadIdx.x
$7 = 1
(cuda-gdb) n
38 r = squareroot(xx + yy);
(cuda-gdb) p x
$8 = 0

You have to convert x back to a long int

x = (long)(delfx * (double)threadIdx.x);

or store x as a double