0
rshift = ((J[i]-1)*((2*net)-J[i]) >> -1);

L[i] = rshift + K[i]-J[i];

when i compile this, i get "error: expression must have integral or enum type" corresponding to the first line. except for 'i' all have double precision.

it works for neither left nor right shift. i'm using fedora 12 and i have nvcc 3.2, V0.2.1221. for c++(g++ compiler), it works perfectly.

but when i tried it for

rshift = ((J[i]-1)*((2*net)-J[i]) >>= -1);

L[i] = rshift + K[i]-J[i];

it was "error: expression must be a modifiable lvalue" i tried a lot and couldn't fix it. any ideas?

Bart
  • 2,062
  • 15
  • 19
Population Xplosive
  • 581
  • 2
  • 8
  • 18
  • 2
    I am not sure I follow. What are you hoping to acheive by performing a shift on double precision floating point values? – talonmies May 26 '11 at 16:41
  • a>>=b is short writing of a=a>>b; you trying to write value to expression which is not an lvalue (not a modificatable entity) – osgx May 26 '11 at 19:39
  • basically i'm trying to convert a fortran program to cuda. @talonmies so do u think that i should change the definition of rshift. @osgx thanx, i was just learning of logical shifts. – Population Xplosive May 27 '11 at 03:01
  • @Population Xplosive: Fortran doesn't have shift operations for floating point numbers either. So whatever you are translating, you have misunderstood something. – talonmies May 27 '11 at 05:26
  • @Population Xplosive: Right. ISHFT is an integer bit shift. And by default in Fortran 77 or earlier, variables whose names start with I,J,K,L,M, or N are implicitly integers. And all of the numerical constants are also integers. I would be incredibly surprised if that code snippet is performing anything other than integer bit shifting. – talonmies May 27 '11 at 07:11
  • > DIMENSION L(ND05) > L(N)=ISHFT((NJ(N)-1)*(2*NET-NJ(N)),-1)+NK(N)-NJ(N) this is the original code in fortran – Population Xplosive May 27 '11 at 07:13
  • so do u think i better change all of them to integers? – Population Xplosive May 27 '11 at 07:16
  • @Population Xplosive: I think you need to pay much closer attention to what the Fortran code might be doing, and it seems like that might entail actually learning some Fortran. You cannot translate an algorithm from one language to another unless you understand fully what the code in the original language is doing. – talonmies May 27 '11 at 07:19

1 Answers1

1

To answer the question - there is no such thing as bit shifting of floating point types in CUDA C (nor C, nor C++). And through questions posted in comments it would appear that the source of the confusion was an incorrect attempt to translate some legacy Fortran code, where there also is no floating point bit shift support.

talonmies
  • 70,661
  • 34
  • 192
  • 269