Send us your feedback or ask for features.
-
highmountain
- Newbie
- Posts:21
- Joined:13 Dec 2011 05:52
bug
Post
by highmountain » 14 Aug 2012 03:32
Make a monitor with a variable named var, set it to 3.
Set the monitor's value and watch what it displays:
Code: Select all
128 & var = 0
2^7 & var = 3
2^7 = 128
-
dsorlien
- Newbie
- Posts:39
- Joined:16 Jan 2012 04:28
Post
by dsorlien » 14 Aug 2012 20:59
I've run into similar issues trying to use bitwise operators.
After some investigation, I realized that the Lemur's bitwise operators '&' and '|' do not work on floating point numbers.
The solution is simple. Use the floor function to convert a floating point number to an integer before using bitwise operation.
Code: Select all
2^7 = 128.000
(2^7) & 3 = 3 <<< wrong answer because (2^7) is a floating point number in Lemur
floor(2^7) = 128
floor(2^7) & 3 = 0 <<< correct answer
-
highmountain
- Newbie
- Posts:21
- Joined:13 Dec 2011 05:52
Post
by highmountain » 15 Aug 2012 00:59
Ah thanks for pointing that out! Makes sense, I guess it didn't register with me that I was getting a float out of it.
That said, exponentiation involving only ints ought to yield ints, so there's still a little bug here (whew).