-
Notifications
You must be signed in to change notification settings - Fork 21
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
Printf format as binary number #1008
Comments
Seems reasonable. You might want to check with OCaml since our printf design largely aligns with that |
https://stackoverflow.com/questions/39962412/why-is-b-deprecated-in-printf |
This would be a useful formatter, but %B having a different function than %b would be confusing. I can't think of another letter that would be intuitive. Maybe %t (for two)? Or if the parser could handle it %2? |
@jackfoxy |
Also |
Darn it, I was looking at an obsolete reference. The problems with searching for documentation... |
@jackfoxy These have been in F# since 1.0. Are you looking at the right language? |
Nope, looked at the first (or at least most prominent) result of a Bing search for "F# printf". |
Ah yes, c-sharpcorner.com, the website deemed as low quality by the C# subreddit. |
For reference, a quick search for "F# printf" got me the official docs for printf specifiers in the language: https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/plaintext-formatting#format-specifiers-for-printf |
@jackfoxy |
Closing as implemented in dotnet/fsharp#11603 |
Printf format as binary number
I propose we allow
printf "%B" 10
which outputs1010
.The existing way of approaching this problem in F# is going through
Convert.ToString(..., 2)
which is not needed for bases 8 and 16.This is arguably used more than base 8.
Pros and Cons
The advantages of making this adjustment to F# are
The disadvantages of making this adjustment to F# are that this brings multiple ways to do the same thing, but then
%o
and%x
/%X
exist.Extra information
Estimated cost (XS, S, M, L, XL, XXL): S
Related suggestions: (put links to related suggestions here)
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
For Readers
If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.
The text was updated successfully, but these errors were encountered: