Skip to content

bitRead and bitWrite documentation ambiguity #924

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

Closed
mjbmikeb2 opened this issue Sep 1, 2023 · 3 comments
Closed

bitRead and bitWrite documentation ambiguity #924

mjbmikeb2 opened this issue Sep 1, 2023 · 3 comments

Comments

@mjbmikeb2
Copy link

bitRead says "Reads a bit of a number."
Is that all signed and unsigned numbers of any size?

bitWrite says, "Writes a bit of a numeric variable"
Again, is that all signed and unsigned numbers of any size?

According to this thread
https://forum.arduino.cc/t/bitread-and-bitwrite-for-numbers-bigger-than-a-byte/1160471
bitWrite doesn't work for 64 bit numbers.

I don't know if this is a bug or a feature. Either way can the documentation please be updated to say what datatypes are currently supported.

Thanks.

@karlsoderby
Copy link
Collaborator

Hi @mjbmikeb2 , thanks for raising the issue. I looked into it, and made some changes to the documentation that hopefully explains things a bit better:

  • Max size to read (64 bits)
  • Max size to write (32 bits)
  • Added an example of how to actually read each individual bit, and print out the raw binary (hopefully the example itself adds some value on how the bitRead() function works as well.
  • float / double are not supported.

Changes here: #933

@mjbmikeb2
Copy link
Author

Typo in https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/bitwrite/

"variables up to an unsigned long (32 bits / 8 bytes)."

Should say 4 bytes.

"variables up to an unsigned long (32 bits / 4 bytes)."

@alranel alranel reopened this Dec 1, 2023
@karlsoderby
Copy link
Collaborator

Hi there @mjbmikeb2 , thanks for spotting it, just been corrected! #960

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

3 participants