Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typo: "first" should be "last" in syntax.md page #15

Closed
jrwdunham opened this issue Apr 16, 2018 · 7 comments
Closed

Typo: "first" should be "last" in syntax.md page #15

jrwdunham opened this issue Apr 16, 2018 · 7 comments

Comments

@jrwdunham
Copy link

On the https://github.com/nishihatapalmer/byteseek/blob/master/syntax.md page where it is written:

 &7f                 # 0x7f = 01111111. Match bytes with all first seven bits set.

I think "first" should be "last", i.e.:

 &7f                 # 0x7f = 01111111. Match bytes with all last seven bits set.
@jrwdunham
Copy link
Author

Oops. Duh. The original wording is correct. I'm reading my binary backwards. Sorry for the noise. Closing.

@nishihatapalmer
Copy link
Owner

Hey, no problem. Thanks for trying to improve byteseek!

@jrwdunham
Copy link
Author

@nishihatapalmer Thanks. Without opening another new issue, is the line ^~87 # 0x87 = 10000111. Match bytes without any of the bitmask bits set. on the same syntax.md page correct? It seems to me that ^~87 should match all bytes with the first three and the last bits unset, i.e.,

00000000
00001000
00010000
00011000
00100000
00101000
00110000
00111000
01000000
01001000
01010000
01011000
01100000
01101000
01110000
01111000

Am I missing something here again?

@nishihatapalmer
Copy link
Owner

That's correct. An any match ~87 on its own would match all the bytes with any of those bits set, but the expression is negated with ^, so it will match all bytes without any of those bits set, which is the list you give.

@nishihatapalmer
Copy link
Owner

A simple way to understand the negation operator ^ is that it gives you a set of bytes containing all the bytes which weren't in the original set.

@jrwdunham
Copy link
Author

Oh, yes, I understand the semantics of ~, ^, and &; I was confused about the wording, but now I see that "without any of the bitmask bits set" means "without any of the bits in 10000111 set", i.e., all integers between 0 and 255 whose binary representation (as a string) starts with 0 and ends with 000.

@nishihatapalmer
Copy link
Owner

I can see how it could be confusing... I'll either have to come up with some better examples, or a better explanation...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants