Infinity: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Add Zig example)
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 213:
Output:
<lang>Infinity</lang>
 
=={{header|C++}}==
 
Line 224 ⟶ 225:
return std::numeric_limits<double>::max();
}</lang>
 
=={{header|Clojure}}==
{{trans|Java}}
Line 287 ⟶ 289:
x:> inf
</pre>
 
=={{header|D}}==
 
Line 386 ⟶ 389:
Infinity
</pre>
 
=={{header|Factor}}==
<lang factor>1/0.</lang>
Line 612 ⟶ 616:
julia> julia> Inf32 == Inf64 == Inf16 == Inf
true
</lang>
 
=={{header|Lingo}}==
Lingo stores floats using IEEE 754 double-precision (64-bit) format.
INF is not a constant that can be used programmatically, but only a special return value.
<lang lingo>x = (1-power(2, -53)) * power(2, 1023) * 2
put ilk(x), x
-- #float 1.79769313486232e308
 
x = (1-power(2, -53)) * power(2, 1023) * 3
put ilk(x), x, -x
-- #float INF -INF</lang>
 
=={{header|Lua}}==
<lang lua>
function infinity()
return 1/0 --lua uses unboxed C floats for all numbers
end
</lang>
 
Line 713 ⟶ 699:
 
decimal
 
=={{header|Lingo}}==
Lingo stores floats using IEEE 754 double-precision (64-bit) format.
INF is not a constant that can be used programmatically, but only a special return value.
<lang lingo>x = (1-power(2, -53)) * power(2, 1023) * 2
put ilk(x), x
-- #float 1.79769313486232e308
 
x = (1-power(2, -53)) * power(2, 1023) * 3
put ilk(x), x, -x
-- #float INF -INF</lang>
 
=={{header|Lua}}==
<lang lua>
function infinity()
return 1/0 --lua uses unboxed C floats for all numbers
end
</lang>
 
=={{header|M2000 Interpreter}}==
Line 900 ⟶ 904:
- : float = infinity
</pre>
 
 
=={{header|Oforth}}==
Line 1,031 ⟶ 1,034:
my $x = inf;
my $y = -inf;</lang>
 
=={{header|Perl 6}}==
Inf support is required by language spec on all abstract Numeric types (in the absence of subset constraints) including Num, Rat and Int types. Native integers cannot support Inf, so attempting to assign Inf will result in an exception; native floats are expected to follow IEEE standards including +/- Inf and NaN.
<lang perl6>my $x = 1.5/0; # Failure: catchable error, if evaluated will return: "Attempt to divide by zero ...
my $y = (1.5/0).Num; # assigns 'Inf'</lang>
 
=={{header|Phix}}==
Line 1,054 ⟶ 1,052:
 
PHP has functions is_finite() and is_infinite() to test for infiniteness.
 
=={{header|PL/I}}==
<lang PL/I>
declare x float, y float (15), z float (18);
 
put skip list (huge(x), huge(y), huge(z));
</lang>
 
=={{header|PicoLisp}}==
Line 1,072 ⟶ 1,063:
: (exp 1000.0)
-> T</lang>
 
=={{header|Perl 6PL/I}}==
<lang PL/I>
declare x float, y float (15), z float (18);
 
put skip list (huge(x), huge(y), huge(z));
</lang>
 
=={{header|PostScript}}==
Line 1,153 ⟶ 1,151:
(define (finite? x) (< -inf.0 x +inf.0))
(define (infinite? x) (not (finite? x)))</lang>
 
=={{header|PL/IRaku}}==
(formerly Perl 6)
Inf support is required by language spec on all abstract Numeric types (in the absence of subset constraints) including Num, Rat and Int types. Native integers cannot support Inf, so attempting to assign Inf will result in an exception; native floats are expected to follow IEEE standards including +/- Inf and NaN.
<lang perl6>my $x = 1.5/0; # Failure: catchable error, if evaluated will return: "Attempt to divide by zero ...
my $y = (1.5/0).Num; # assigns 'Inf'</lang>
 
=={{header|REXX}}==
Line 1,203 ⟶ 1,207:
0
</lang>
 
 
=={{header|Ruby}}==
10,327

edits