Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Digit Separator in Julia

Coding in Julia shows that using underscore as integer digit separator works in Julia.

x = 1_000_000

and

   x = 1000000

are basically the same thing.

However, I am not able to locate the documentation for this, to read more details. Could anyone point me to that.

Also is digit separation character a common thing in different languages? What are the separator character in C++, java, and Python?

like image 466
user25004 Avatar asked Sep 08 '25 03:09

user25004


1 Answers

The standards proposal document for C++14 has a very lengthy discussion on the rationale and possible choices for a digit separator. The considered `, ', _, ::, and (space). Some of the discussion cites other languages. According to the document, _ is also used in Ada, VHDL, Verilog, and possibly Algol68. Underscores also appear to be used in Java 7 (StackOverflow question, proposal). C++ settled on ' as their separator.

Julia hasn't formally documented underscore-separated numeric literals yet, but you can find some information in this GitHub issue (#848) and this julia-dev thread.

It doesn't look like Python has a numeric literal separator.

like image 194
mbauman Avatar answered Sep 10 '25 00:09

mbauman