Literals/Floating point: Difference between revisions

m
→‎{{header|Phix}}: added syntax colouring the hard way, phix/basics
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>?1e+12 -- (same as 1e12)>
<span style="color: #0000FF;">?</span><span style="color: #000000;">1e+12</span> <span style="color: #000080;font-style:italic;">-- (same as 1e12)</span>
?1e-12
<span style="color: #0000FF;">?</span><span style="color: #000000;">1e-12</span>
?5 -- (same as 5.0)
<span style="color: #0000FF;">?</span><span style="color: #000000;">5</span> <span style="color: #000080;font-style:italic;">-- (same as 5.0)
--?1. -- (illegal, use 1 or 1.0)
--?.1 . -- (sameillegal, asuse 0.1 or 1.0)</span>
<span style="color: #0000FF;">?.</span><span style="color: #000000;">1</span> <span style="color: #000080;font-style:italic;">-- (same as 0.1)</span>
?1/3 -- 0.333333
<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>
printf(1,"%g %G\n",1e-30)</lang>
<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>
7,795

edits