Skip to content

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

Open
Pr0gm4n wants to merge 1 commit intojaparic:mainfrom
Pr0gm4n:main
Open

add binary formatting (proof-of-concept)#54
Pr0gm4n wants to merge 1 commit intojaparic:mainfrom
Pr0gm4n:main

Conversation

@Pr0gm4n
Copy link
Copy Markdown

@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.

1 participant