Page 1 of 1
Pow(0,0) = 1
Posted: Fri Jun 14, 2024 4:00 pm
by matalog
Is there any way to avoid the likes of
Code: Select all
For y=0 To 7 ; lvp=lvp+Pow(Bool(Point(x,y+h)>#Black)*2,(7-y)) ; Next
Returning 1 when both parts of the Pow() are zero?
Re: Pow(0,0) = 1
Posted: Fri Jun 14, 2024 4:03 pm
by Mindphazer
Re: Pow(0,0) = 1
Posted: Fri Jun 14, 2024 4:13 pm
by matalog
Yeah, I was using it badly, this works:
Code: Select all
For y=0 To 7
lvp=lvp+Pow(2,(7-y))*Bool(Point(x,y+h)>#Black)
Next
Re: Pow(0,0) = 1
Posted: Fri Jun 14, 2024 6:21 pm
by NicTheQuick
Better use the shift operator instead of Pow() if the base is 2 and your exponent an integer:
Pow() is using floats which is slower than a simple shift operation.
Re: Pow(0,0) = 1
Posted: Sat Jun 15, 2024 10:23 am
by matalog
NicTheQuick wrote: Fri Jun 14, 2024 6:21 pm
Better use the shift operator instead of Pow() if the base is 2 and your exponent an integer:
Pow() is using floats which is slower than a simple shift operation.
Great, thanks.