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

add binary formatting (proof-of-concept) #54

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Pr0gm4n
Copy link

@Pr0gm4n Pr0gm4n commented Jan 22, 2023

Hello there!

I wanted to suggest adding binary/octal (and potentially exponential for f32/f64) formatting support for numbers. As a proof-of-concept, I have adjusted the structures needed for hex-formatting to showcase that the same workflow would work with the other mentioned types. I would even expect that we could create a unified interface & macros for the definitions for the impl blocks.

Some thoughts:

  • It seems that the only thing that changes is the mask (0xf vs. 0b1) and the bitshift operation, as well as some constant (e.g. the prefix would be 0b).
  • More precisely, if you have a bit shift by x, then your mask is 2.pow(x) - 1 – maybe that could be used in the macro as well.
  • The HexOptions struct could be renamed and reused for all those number format options, I believe.

What's your opinion on this? Are there any plans to include such functionality anyways?

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

Successfully merging this pull request may close these issues.

None yet

1 participant