-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 reference to _
as digit separator.
#12253
Conversation
Perhaps add more examples? |
julia> 1_000 | ||
1000 | ||
|
||
julia> 10_000.10_001 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the normal breaking place here be 10_000.100_01 (i.e. at the 1000's places)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True!
I could also squeeze more examples with hexadecimal. etc in the same line with tuples:
julia> 10_000, 0_000.100_01, 0xdead_beef, 0b101_001
(10000,0.10001,0xdeadbeef,0x29)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be more likely with 0b to have _ every 4, instead of 3? (i.e. same as hex digit).
I think for floating point, maybe a better example would be something like:
0.000_000_050
(i.e. 50 nano whatever)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the other examples, this documentation is nice to have, I never even knew julia had a digits separator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this is the right place in the document to put this? I put this after the explanation of integers and floating points literals because it applies to all numeric types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe in front, because looking at it again, it is really in the middle of the floating point section.
Maybe it should not appear in the floating point section since it works for integers too. What about a small paragrah about all the ways to write 10^4 ? (1e4 is a floating point but 10_000 and 10^4 are integers). After all both e and _ are special symbols. |
@matthieugomez that's also what I thought I'll change the paragraph near the end, and reference both symbols special cases, thanks! |
Add reference to `_` as digit separator.
Note: Algol68 sidestepped the entire issue by allowing a space in a number, for example: 1 million could be 1 000 000, and π could be 3.14159 26535 89793 23846 ... Decimal Exponent Symbol is part of "The Unicode Standard" e.g. 6.0221415⏨23 - it is included as U+23E8 ⏨ decimal exponent symbol to accommodate usage in the programming languages Algol 60 and Algol 68. cf. http://www.fileformat.info/info/unicode/char/23e8/index.htm |
Ref: http://stackoverflow.com/questions/31546263/digit-separator-in-julia
[av skip]