Check Whether a Byte Is Nonzero
Problem statement
Given a nonnegative 64-bit integer value and a zero-based byte index byteIndex, return whether the selected byte is nonzero.
Byte index 0 is the least-significant byte. Each byte contains 8 bits.
Function
isByteNonzero(value: long, byteIndex: int) → booleanExamples
Example 1
value = 305419896byteIndex = 0return = trueThe least-significant byte is hexadecimal 78, which is nonzero.
Example 2
value = 16711680byteIndex = 1return = falseThe value is hexadecimal 00FF0000; byte index 1 is 00.
Example 3
value = 0byteIndex = 7return = falseEvery byte of zero is zero.
Constraints
0 <= value <= 2^63 - 10 <= byteIndex <= 7