Jump to content

Literals/Floating point: Difference between revisions

Add Factor example
m (→‎{{header|360 Assembly}}: Add a wikipedia link)
(Add Factor example)
Line 336:
Floating Point or Exponential: 10, 16.1235, 64, 1.23457e+008
</pre>
 
=={{header|Factor}}==
<lang factor>3.14 ! basic float
+3.14 ! Optional signs
-3.14
10e5 ! exponents signified by e or E
10E+5 ! with optional signs
+10e-5
1. ! equivalent to 1.0
.5 ! equivalent to 0.5
1/2. ! floating point approximation of a ratio (0.5)
1/3. ! 0.3333333333333333
1/0. ! positive infinity
-1/0. ! negative infinity
0/0. ! not-a-number
! hexadecimal, octal, and binary float literals are supported.
! they require a base 2 exponent followed by p or P.
0x1.0p3 ! 8.0
-0x1.0P-3 ! -0.125
0b1.010001p3 ! 10.125
0o1.21p3 ! 10.125
! comma separators are allowed
1,234.123,456 ! 1234.123456
 
 
! normalized hex form ±0x1.MMMMMMMMMMMMMp±EEEE allows any floating-point
! number to be specified precisely according to IEEE 754 representation
+0x1.1234567891234p+0002 ! 4.28444444440952</lang>
 
=={{header|Forth}}==
1,827

edits

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