0

Extracting an nth bit from a decimal

I'm trying to use the right shift (>>) operator to extract an nth bit from a decimal and its giving me an error: Value was either too large or too small for a UInt16". 

Here is an example : 62914560 >> 0

How do I solve this one?

1 reply

null
    • laruer
    • 11 mths ago
    • Reported - view

    If you want to do a right shift you can use a combination of the Floor and Pow functions.
     

    Floor(number / Pow(2,shift))

    In the case of your example, let's do a right shift of 5 bits:

    Floor(62914560 / Pow(2,5)) = 1966080

    Which is the same as doing:

    62914560 >> 5
    

    This can be used in a calculation or in a value transform.

Content aside

print this pagePrint this page
  • 11 mths agoLast active
  • 1Replies
  • 44Views
  • 2 Following