Numeric separator syntax: Difference between revisions

Scala contribution added.
(Added Algol 68)
(Scala contribution added.)
Line 255:
- 1719
 
=={{header|Scala}}==
Since Scala 2.13.0 it's stated in the Scala Language Specification that:
''"The digits of a numeric literal may be separated by arbitrarily many underscores for purposes of legibility."''
Let's see how its work in a Scala REPL session:
<lang Scala>Welcome to Scala 2.13.0 (Java HotSpot(TM) 64-Bit Server VM, Java 12.0.2).
Type in expressions for evaluation. Or try :help.
 
scala> // Integer Literals
 
scala> // Using _ as a separator (neither leading nor trailing) it can be placed anywhere in the number.
 
scala> 1_2_3
res0: Int = 123
 
scala> 0xa_bc_d
res1: Int = 43981
 
scala> 0x_dead_beef
res2: Int = -559038737
 
scala> 1_2_3_4.2_5
res3: Double = 1234.25
 
scala> 6.0_22e4
res4: Double = 60220.0
 
scala> 12__34.25
res5: Double = 1234.25
 
scala></lang>
=={{header|Sidef}}==
Sidef allows underscores as a separator character in numeric inputs.
Line 272 ⟶ 302:
say 6.0_22e4; # 60220
 
# Apart from starting the number with an undercoreunderscore, it can be placed anywhere in the number.
 
say 1234_.25; # 1234.25
Anonymous user