Jump to content

Literals/Floating point: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 313:
1.23E4
</lang>
 
=={{header|Elena}}==
<lang elena>real r := 1;
Line 513 ⟶ 514:
The function write will cause the real values to be coerced as string constants. Icon/Unicon will format these as it sees fit resorting to exponent forms only where needed.
{{libheader|Icon Programming Library}}
[http://www.cs.arizona.edu/icon/library/src/procs/printf The IPL library routine printf provides a broader range of formatting choices.]
 
=={{header|J}}==
Line 565 ⟶ 566:
 
Note that all the values in an array are the same type, thus the 0, 1 and 2 in the above example are floating point because they do not appear by themselves. Note also that by default J displays no more than six significant digits of floating point values.
 
=={{header|jq}}==
jq floating point literals are identical to JSON floating point literals. However, when jq parses a floating point or integer literal, conversion to IEEE 754 numbers takes place, which may result in a loss of accuracy and/or an apparent change of type, as illustrated by the following sequence of input => output pairs:
<lang sh>1.0 => 1
1.2 => 1.2
1e10 => 10000000000
1e100 => 1e+100
1e1234 => 1.7976931348623157e+308
.1 => 0.1
.1e1 => 1</lang>
 
=={{header|Java}}==
Line 591 ⟶ 582:
1 / 2 //int equal to 0</lang>
Values that are outside the bounds of a type will give compiler errors when trying to force them to that type.
 
=={{header|jq}}==
jq floating point literals are identical to JSON floating point literals. However, when jq parses a floating point or integer literal, conversion to IEEE 754 numbers takes place, which may result in a loss of accuracy and/or an apparent change of type, as illustrated by the following sequence of input => output pairs:
<lang sh>1.0 => 1
1.2 => 1.2
1e10 => 10000000000
1e100 => 1e+100
1e1234 => 1.7976931348623157e+308
.1 => 0.1
.1e1 => 1</lang>
 
=={{header|Julia}}==
Line 971 ⟶ 972:
100_000_000; # equals to 100000000
</lang>
 
=={{header|Perl 6}}==
Floating point numbers (the Num type) are written in the standard 'e' scientific notation:
<lang perl6>2e2 # same as 200e0, 2e2, 200.0e0 and 2.0e2
6.02e23
-2e48
1e-9
1e0</lang>
 
A number like <tt>3.1416</tt> is specifically not floating point, but rational (the Rat type), equivalent to <tt>3927/1250</tt>. On the other hand, <tt>Num(3.1416)</tt> would be considered a floating literal though by virtue of mandatory constant folding.
 
=={{header|Phix}}==
Line 1,100 ⟶ 1,091:
1.0t0
</pre>
 
=={{header|Perl 6Raku}}==
(formerly Perl 6)
Floating point numbers (the Num type) are written in the standard 'e' scientific notation:
<lang perl6>2e2 # same as 200e0, 2e2, 200.0e0 and 2.0e2
6.02e23
-2e48
1e-9
1e0</lang>
 
A number like <tt>3.1416</tt> is specifically not floating point, but rational (the Rat type), equivalent to <tt>3927/1250</tt>. On the other hand, <tt>Num(3.1416)</tt> would be considered a floating literal though by virtue of mandatory constant folding.
 
=={{header|REXX}}==
Line 1,220 ⟶ 1,222:
base 2 mantissa and base 2 exponent:
<lang smalltalk>2r1010e2r0101 -> 320.0</lang>
 
=={{header|Stata}}==
Only decimal floating-point are supported, computations are done in double precision (but storage can be made in integer or single floating-point as well).
10,333

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.