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

Update comment to resolve ambiguity #120282

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mahmudsudo
Copy link

The documentation is incorrect as the determinant for lower or upper case is the 5th bit not the 6th bit as written in the codebase.
An excerpt from the book the art of assembly language lays credence to this :
"Upper case characters always contain a zero in bit five; lower case alphabetic characters always contain a one in bit five. You
can use this fact to quickly convert between upper and lower case. If you have an upper
case character you can force it to lower case by setting bit five to one."

The documentation is incorrect as the determinant for lower or upper case is the 5th bit not the 6th bit as written in the codebase.
@rustbot
Copy link
Collaborator

rustbot commented Jan 23, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 23, 2024
@klensy
Copy link
Contributor

klensy commented Jan 23, 2024

For ref #118236

@slanterns
Copy link
Contributor

slanterns commented Jan 23, 2024

Simply wrong. 'O' = 79 = 0b01001111, 'P' = 80 = 0b01010000. Don't rely on the book without actually checking it :)
(And if you read the code, it's also const ASCII_CASE_MASK: u8 = 0b0010_0000 masking the 6th bit.)

@mahmudsudo
Copy link
Author

E = 0 1 0 0 0 1 0 1
e = 0 1 1 0 0 1 0 1
The bit that determines the case of an ascii letter is the FIFTH BIT counted from the low order bit , this is further explained in the example given above

@mahmudsudo
Copy link
Author

Incase we are still not clear ,the low order bit is the rightmost bit ,it has a place value of zero , hence called the zero bit , any bit number is counted from the zero bit as origin .

@slanterns
Copy link
Contributor

slanterns commented Jan 23, 2024

I get what makes you confused and apologize for my misunderstanding. However I just found that most people will call it the 6th bit by https://www.google.com/search?q=ascii+capital+bit+xor.

@mahmudsudo
Copy link
Author

Simply wrong. 'O' = 79 = 0b01001111, 'P' = 80 = 0b01010000. Don't rely on the book without actually checking it. (And if you read the code, it's also const ASCII_CASE_MASK: u8 = 0b0010_0000 masking the 6th bit.)

nothing i said is actually wrong as pointed out by you ,
O = 01001111
o= 01101111
as shown the fifth bit (with the Low order bit as zero bit ) is the distinguishing factor not 6th bit )

@mahmudsudo
Copy link
Author

I get what makes you confused. However I just found most people will call it the 6th bit by https://www.google.com/search?q=ascii+capital+bit+xor.

The usage by people doesnt make the counting standard
An 8 bit value is numbered X_0_ -- X_7_ even though there are 8 bits , the academia uses the fifth bit as the distinguisher between lowercase and uppercase .

@mahmudsudo
Copy link
Author

Simply wrong. 'O' = 79 = 0b01001111, 'P' = 80 = 0b01010000. Don't rely on the book without actually checking it. (And if you read the code, it's also const ASCII_CASE_MASK: u8 = 0b0010_0000 masking the 6th bit.)

nothing i said is actually wrong as pointed out by you , O = 01001111 o= 01101111 as shown the fifth bit (with the Low order bit as zero bit ) is the distinguishing factor not 6th bit )

https://www.geeksforgeeks.org/program-toggle-characters-string/

@Teapot4195
Copy link
Contributor

Honestly we shouldn't be arguing over whether to call it 5th or 6th bit, both are equally confusing unless a labeled byte diagram is provided both 5 and 6 are valid. If you really wanted to know which bit was being masked a quick google search would tell you which bit is being masked

@slanterns
Copy link
Contributor

slanterns commented Jan 23, 2024

The usage by people doesnt make the counting standard

If you prefer standards, in ISO-IR-6: ASCII Graphic character set or ANSI INCITS 4-1986 they are called b1..b7 (since b8 is not used).
I feel arguing for things like that is just not so meaningful, and at least the comments are in a consistent state now while the edit will break it again :(

@Mark-Simulacrum
Copy link
Member

r=me with suggestion or equivalent text applied and squashed into one commit. Otherwise I'm not inclined to change one number to the other; both seem equally not helpful to me.

adequate changes made

Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
@Teapot4195
Copy link
Contributor

Squash please

@Mark-Simulacrum Mark-Simulacrum changed the title Update mod.rs Update documentation comment to resolve ambiguity Feb 4, 2024
@Mark-Simulacrum Mark-Simulacrum changed the title Update documentation comment to resolve ambiguity Update comment to resolve ambiguity Feb 4, 2024
@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 4, 2024
@Dylan-DPC
Copy link
Member

@mahmudsudo any updates on this?

@mahmudsudo
Copy link
Author

I have resolved the suggested change to the commit

@Dylan-DPC Dylan-DPC added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 24, 2024
@Mark-Simulacrum
Copy link
Member

This still needs to be squashed.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants