Literals/Floating point: Difference between revisions
Content deleted Content added
Drkameleon (talk | contribs) |
Thundergnat (talk | contribs) Rename Perl 6 -> Raku, alphabetize, minor clean-up |
||
Line 313: | Line 313: | ||
1.23E4 |
1.23E4 |
||
</lang> |
</lang> |
||
=={{header|Elena}}== |
=={{header|Elena}}== |
||
<lang elena>real r := 1; |
<lang elena>real r := 1; |
||
Line 513: | Line 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. |
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}} |
{{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.] |
[http://www.cs.arizona.edu/icon/library/src/procs/printf The IPL library routine printf provides a broader range of formatting choices.] |
||
=={{header|J}}== |
=={{header|J}}== |
||
Line 565: | Line 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. |
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. |
||
⚫ | |||
⚫ | 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: |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Java}}== |
=={{header|Java}}== |
||
Line 591: | Line 582: | ||
1 / 2 //int equal to 0</lang> |
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. |
Values that are outside the bounds of a type will give compiler errors when trying to force them to that type. |
||
⚫ | |||
⚫ | 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: |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
Line 971: | Line 972: | ||
100_000_000; # equals to 100000000 |
100_000_000; # equals to 100000000 |
||
</lang> |
</lang> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
Line 1,100: | Line 1,091: | ||
1.0t0 |
1.0t0 |
||
</pre> |
</pre> |
||
⚫ | |||
(formerly Perl 6) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
Line 1,220: | Line 1,222: | ||
base 2 mantissa and base 2 exponent: |
base 2 mantissa and base 2 exponent: |
||
<lang smalltalk>2r1010e2r0101 -> 320.0</lang> |
<lang smalltalk>2r1010e2r0101 -> 320.0</lang> |
||
=={{header|Stata}}== |
=={{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). |
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). |