Page 1 of 1
Cannot use btiwise operators in expression assigned to float
Posted: Thu Jan 07, 2016 9:32 pm
by Mistrel
I just realized that we cannot do this:
It produces an error:
Can't use any of the following operands with floats: <<, >>, &, |, !, %.
But we can do this:
Code: Select all
Integer=Integer&$FFFF
Float.f=Integer
Am I missing something?

Re: Cannot use btiwise operators in expression assigned to f
Posted: Thu Jan 07, 2016 9:36 pm
by Tenaja
My guess would be, since it is a float assignment, the integer is converted to a float first, and that causes the err since we cannot do bit operations on floats.
Re: Cannot use btiwise operators in expression assigned to f
Posted: Thu Jan 07, 2016 9:52 pm
by sys64802
It shouldn't because it's clearly limiting and the integer expression "Integer & $FFFF" should be evalued and then converted to float to be assigned, but it's how the PB compiler has been written.
Re: Cannot use btiwise operators in expression assigned to f
Posted: Thu Jan 07, 2016 10:28 pm
by Mistrel
I always thought that promotion came after evaluating an expression in a similar fashion to C. This definitely is not the case:
Code: Select all
LongA.l=2147483647
LongB.l=2147483647
Quad.q=LongA*LongB
Debug Quad.q
Re: Cannot use btiwise operators in expression assigned to f
Posted: Thu Jan 07, 2016 10:36 pm
by Tenaja
I am pretty sure PB promotes immediately after the first float is found.
Re: Cannot use btiwise operators in expression assigned to f
Posted: Thu Jan 07, 2016 11:31 pm
by Mistrel
This doesn't work either and reports the same error:
Re: Cannot use btiwise operators in expression assigned to f
Posted: Fri Jan 08, 2016 12:06 am
by sys64802
Unsurprisingly since "&" doesn't work with floats, as the popup error reminds you.
This is different:
You don't have a float as operand for "&" here, so it should work, and then cast the result.
Re: Cannot use btiwise operators in expression assigned to f
Posted: Fri Jan 08, 2016 12:45 am
by Mistrel
I know that. It's just that it seemed as though promotion is done before the expression but in second case it is not. So the rules seem inconsistent?