I need to use the code below, but I'm new to ruby and programming in general and don't understand what this does. Can someone tell me what this does or at least what this is called?
def MAKELPARAM(w1, w2)
return (w2<<16) | w1
end
Thanks!
This performs a left-shift of w2 by 16 bits, then bitwise-or's w1 into the result.
So those could be bitwise operators if you know that they are numbers however if the params coming in are arrays then << is the operator to add to the array. Also then the | operator does an or on the two array's returning an array of the elements that are in either array
For Example:
w1 =[]
w2 = [16,13]
w3 = [13]
MAKELPARAM(w1,w2)
#Returns [16,13]
MAKELPARAM(w1,w3)
#Returns [16,13]
MAKELPARAM(w1,w1)
#Returns [16]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With