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 reference to _ as digit separator. #12253

Merged
merged 1 commit into from
Jul 28, 2015
Merged

Add reference to _ as digit separator. #12253

merged 1 commit into from
Jul 28, 2015

Conversation

Ismael-VC
Copy link
Contributor

@Ismael-VC
Copy link
Contributor Author

Perhaps add more examples?

julia> 1_000
1000

julia> 10_000.10_001
Copy link
Contributor

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)

Copy link
Contributor Author

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)

Copy link
Contributor

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)

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@matthieugomez
Copy link
Contributor

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.

@Ismael-VC
Copy link
Contributor Author

@matthieugomez that's also what I thought I'll change the paragraph near the end, and reference both symbols special cases, thanks!

JeffBezanson added a commit that referenced this pull request Jul 28, 2015
Add reference to `_` as digit separator.
@JeffBezanson JeffBezanson merged commit 721bdbe into JuliaLang:master Jul 28, 2015
@NevilleDNZ
Copy link

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

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.

5 participants