Created
January 20, 2020 02:45
-
-
Save vinniefalco/d0dd4b2f9b5856de3cfcb564c6b64095 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// return `true` if the hex | |
// word could be 0..255 if | |
// interpreted as decimal | |
bool | |
maybe_octet(long word) | |
{ | |
if(word > 0x255) | |
return false; | |
unsigned short d1 = | |
(word >> 8) & 0xf; | |
if(d1 > 2) | |
return false; | |
unsigned short d2 = | |
(word >> 4) & 0xf;; | |
if(d2 > 9) | |
return false; | |
unsigned short d3 = | |
word & 0xf; | |
if(d3 > 9) | |
return false; | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment