Literals/Floating point: Difference between revisions
m
→{{header|Phix}}: added syntax colouring the hard way, phix/basics
Drkameleon (talk | contribs) |
m (→{{header|Phix}}: added syntax colouring the hard way, phix/basics) |
||
Line 988:
=={{header|Phix}}==
{{libheader|Phix/basics}}
Phix does not require any distinction between integers and floats: 5 and 5.0 are exactly the same.
A variable declared as atom can hold an integer or a floating point value.<br>
Line 998 ⟶ 999:
and on a 64-bit architecture they can range from approximately -1e4932 to +1e4932 with 19 decimal digits.<br>
The included bigatom library allows working with extremely large integers and floats with arbitrary precision. In the following, '?x' is the Phix shorthand for 'print(1,x)', plus \n
<!--<lang Phix>
<span style="color: #0000FF;">?</span><span style="color: #000000;">1e+12</span> <span style="color: #000080;font-style:italic;">-- (same as 1e12)</span>
<span style="color: #0000FF;">?</span><span style="color: #000000;">1e-12</span>
<span style="color: #0000FF;">?</span><span style="color: #000000;">5</span> <span style="color: #000080;font-style:italic;">-- (same as 5.0)
--?
<span style="color: #0000FF;">?.</span><span style="color: #000000;">1</span> <span style="color: #000080;font-style:italic;">-- (same as 0.1)</span>
<span style="color: #0000FF;">?</span><span style="color: #000000;">1</span><span style="color: #0000FF;">/</span><span style="color: #000000;">3</span> <span style="color: #000080;font-style:italic;">-- 0.333333</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%g %G\n"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1e-30</span><span style="color: #0000FF;">)</span>
<!--</lang>-->
{{out}}
<pre>
|