Page 1 of 1

Syntax Error: rDouble = (iInteger >> 10)

Posted: Tue Sep 03, 2024 4:12 pm
by PeDe
PB v6.04/6.12b3, Windows 7

Why does the last line in the code Not work?

Peter

Code: Select all

Define rDouble.d
Define iInteger.i
iInteger = 4096
rDouble = (iInteger / 1024)
rDouble = (4096 >> 10)
rDouble = (iInteger >> 10)

; ---------------------------
; PureBasic
; ---------------------------
; Line 6: Can't use any of the following operands with float or double: <<, >>, &, |, !, %.
; ---------------------------
; OK   
; ---------------------------

Re: Syntax Error: rDouble = (iInteger >> 10)

Posted: Tue Sep 03, 2024 4:16 pm
by Fred
When assigning to a double, the whole expression is casted to double, even if parenthesis are used. Constants are resolved at compile time, that's why it's a bit different.

Re: Syntax Error: rDouble = (iInteger >> 10)

Posted: Tue Sep 03, 2024 4:21 pm
by PeDe
Ok, thanks. I noticed the syntax error with FormatNumber() and I didn't understand it.

Peter