Infinity: Difference between revisions
m
→{{header|Fōrmulæ}}
(12 intermediate revisions by 6 users not shown) | |||
Line 205:
==={{header|bootBASIC}}===
There are no floating point numbers in bootBASIC. All numbers and variables are 2 byte unsigned integers.
The code below can't print anything on the screen, plus the program won't end. No way is currently known to break out of the program.
<syntaxhighlight lang="
=={{header|BQN}}==
Line 376 ⟶ 378:
return Infinity # predefined variable holding positive infinity
}</syntaxhighlight>
=={{header|EasyLang}}==
<syntaxhighlight>
print number "inf"
# or
print 1 / 0
</syntaxhighlight>
=={{header|Eiffel}}==
Line 527 ⟶ 537:
{{FormulaeEntry|page=https://formulae.org/?script=examples/Infinity}}
'''Solution'''
Fōrmulæ does not use floating point numbers, but arbitrary-size integers and arbitrary-precision decimal numbers.
Infinity is a predefined expression in Fōrmulæ.
Reduction of certain expressions can produce it:
[[File:Fōrmulæ - Infinity 01.png]]
[[File:Fōrmulæ - Infinity 02.png]]
=={{header|GAP}}==
Line 678 ⟶ 700:
=={{header|jq}}==
Sufficiently recent versions of the C, Go and Rust implementations of jq (jq, gojq, and jaq, respectively) all allow `infinite` as a scalar value in jq programs; jq and gojq display its value as 1.7976931348623157e+308. The C implementation also allows the token `inf` when reading JSON, and stores it as `infinite`.
jq uses IEEE 754 64-bit floating-point arithmetic, and very large number literals, e.g. 1e1000, are evaluated as IEEE 754 infinity. If your version of jq does not include `infinite` as a built-in, you could therefore define it as follows:▼
▲The C implementation of jq uses IEEE 754 64-bit floating-point arithmetic, and very large real number literals, e.g. 1e1000, are evaluated as IEEE 754 infinity
<syntaxhighlight lang="jq">def infinite: 1e1000;</syntaxhighlight>
To test whether a jq value is equal to `infinite` or `- infinite`, one can
=={{header|Julia}}==
Line 1,592 ⟶ 1,612:
=={{header|Wren}}==
Wren certainly supports infinity for floating point numbers as we already have a method ''Num.isInfinity'' to test for it.
<syntaxhighlight lang="
var y = x / 0
System.print("x = %(x)")
Line 1,628 ⟶ 1,648:
=={{header|Zig}}==
'''Works with:''' 0.10.x, 0.11.x, 0.12.0-dev.1577+9ad03b628
Assumes that defaul float optimization mode was not changed via @setFloatMode (performed in Strict mode, not Optimized, latter is equivalent to -ffast-math).
<syntaxhighlight lang="zig">const std = @import("std");
const math = std.math;
test "infinity" {
const
const float_types = [_]type{ f16, f32, f64, f80, f128, c_longdouble };
inline for (float_types) |T| {
const infinite_value: T = comptime std.math.inf(T);
}
}</syntaxhighlight>
{{out}}
<pre>
$ zig test src/infinity_float.zig
All 1 tests passed.
</pre>
=={{header|zkl}}==
|