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

Underscores only every 2^n digits in non-decimal numbers #2538

Closed
l0b0 opened this issue Mar 17, 2018 · 4 comments · Fixed by #6183
Closed

Underscores only every 2^n digits in non-decimal numbers #2538

l0b0 opened this issue Mar 17, 2018 · 4 comments · Fixed by #6183

Comments

@l0b0
Copy link

l0b0 commented Mar 17, 2018

What it does: Warns if an integral or floating point non-decimal number is split somewhere other than between n^2 and (n^2)+1 (for constant n≥1). Hexadecimal, octal and binary numbers are used when dealing with 2^n fractions or multiples of bytes.

Examples:

  • 0xabc_def. Probably what was meant was 0xab_cdef, 0xab_cd_ef or there's a missing nibble in the second half.
  • 0xa_b_c_d_e_f is more verbose but no clearer than 0xabcdef.
@Manishearth
Copy link
Member

I see use cases for splitting this at other points (e.g. a bit mask with different groups of masks) but that seems minor in this case and there aren't other issues so this seems fine.

Though the description isn't quite accurate, it should be between powers of four.

@l0b0
Copy link
Author

l0b0 commented Mar 17, 2018

Though the description isn't quite accurate, it should be between powers of four.

In most cases I'd agree, but I guess a fairly common pattern would be splitting hexadecimal between bytes, as in 0xab_cd_ef.

@Manishearth
Copy link
Member

Sorry, powers of eight. Not n^2

@l0b0
Copy link
Author

l0b0 commented Mar 17, 2018

Ah, we meant the same thing. To clarify, I meant the most natural splits are nibbles (0b1111_0000) or bytes (0b11111111_00000000) for binary, and bytes (0xff) or words for hex.

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