-->
Page 1 of 1

Help with logic operator

PostPosted: Thu Feb 26, 2015 6:18 pm
by GWizez
Hi every one,

I'm new in Lua programming, I am usually working in C++

There is this sentence I need to translate in Lua and I just don't know how to formulate it:

Code: Select allThis is the sentence in C++

 bits[x] |= (1 << cnt)



Could any one be kind and help me in this task?

Re: Help with logic operator

PostPosted: Wed Mar 04, 2015 8:18 pm
by dpwhittaker
Bitwise operators are a library function in nodemcu.

Try:

Code: Select allbits[x] = bit.bor(bits[x], bit.lshift(1,cnt))


https://github.com/nodemcu/nodemcu-firm ... _en#bitbor

Re: Help with logic operator

PostPosted: Wed Mar 04, 2015 9:35 pm
by GWizez
Oh! I can do it all in one line? I kinda found the answer yesterday but I I had to do it in 2 steps. Wow! thank you this will save lot of space. Thank you again. :D