RSHIFT compiler warning
TonyAngelo
Posts: 315
I'm getting a compiler warning Converting type LONG to INTERGER with this function, specificaly the RSHIFT. When I remove the RSHIFT it compiles fine.
DEFINE_FUNCTION INTEGER[2] fnWord12(CHAR Word[])
{
STACK_VAR INTEGER Result[2]
Result[1] = ($1F BAND Word[1]) // First piece of info is in the first five bits
Result[2] = ($03 BAND (Word[1] RSHIFT 5)) // second piece of info is in bits 6&7
RETURN Result;
}
Is there something about RSHIFT I'm not understanding?
DEFINE_FUNCTION INTEGER[2] fnWord12(CHAR Word[])
{
STACK_VAR INTEGER Result[2]
Result[1] = ($1F BAND Word[1]) // First piece of info is in the first five bits
Result[2] = ($03 BAND (Word[1] RSHIFT 5)) // second piece of info is in bits 6&7
RETURN Result;
}
Is there something about RSHIFT I'm not understanding?
0
Comments
Result[2] = TYPE_CAST(($03 BAND (Word[1] RSHIFT 5)))
I suppose it's because the Variable Word[] was initialized a CHAR and its assigned to an INTEGER
I don't believe that's the case. It's giving me a LONG to INTEGER warning and when I comment out the Result[2] line I get no warnings. The Result[1] line which does the same thing (assigns the BANDed result of Word[] to an integer) gives me no problems.
TYPE_CAST will work, but I just wanted to make sure this was the right way to use RSHIFT and I wasn't missing something.
Sometimes you do, and sometimes you don't need to type_cast - so don't worry about it.
Counter-examples welcomed...