Just starting out? Need help? Post your questions and find answers here.
-
matalog
- Enthusiast

- Posts: 305
- Joined: Tue Sep 05, 2017 10:07 am
Post
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?
Last edited by
matalog on Fri Jun 14, 2024 4:05 pm, edited 1 time in total.
-
Mindphazer
- Enthusiast

- Posts: 487
- Joined: Mon Sep 10, 2012 10:41 am
- Location: Savoie
Post
by Mindphazer »
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
-
matalog
- Enthusiast

- Posts: 305
- Joined: Tue Sep 05, 2017 10:07 am
Post
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
-
NicTheQuick
- Addict

- Posts: 1527
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
-
Contact:
Post
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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
-
matalog
- Enthusiast

- Posts: 305
- Joined: Tue Sep 05, 2017 10:07 am
Post
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.