سؤال

What's the easiest way to get two nibbles (as Integers) from a byte in Ruby?

هل كانت مفيدة؟

المحلول

If the "byte" is a number between 0 and 255:

n1, n2 = (byte & 0xf0) >> 4, byte & 0x0f
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top