Infinity: Difference between revisions
Content added Content deleted
Langurmonkey (talk | contribs) (removed langur language example; It looks like langur 0.8 will not have infinity at all.) |
(Add Zig example) |
||
Line 1,425: | Line 1,425: | ||
<lang Yabasic>infinity = 1e300*1e300 |
<lang Yabasic>infinity = 1e300*1e300 |
||
if str$(infinity) = "inf" print "Infinity"</lang> |
if str$(infinity) = "inf" print "Infinity"</lang> |
||
=={{header|Zig}}== |
|||
<lang zig>const std = @import("std"); |
|||
const debug = std.debug; |
|||
const math = std.math; |
|||
test "infinity" { |
|||
const infinite_f16 = math.inf(f16); |
|||
const infinite_f32 = math.inf(f32); |
|||
const infinite_f64 = math.inf(f64); |
|||
const infinite_f128 = math.inf(f128); |
|||
// Any other types besides these four floating types are not implemented. |
|||
debug.assert(math.isInf(infinite_f16)); |
|||
debug.assert(math.isInf(infinite_f32)); |
|||
debug.assert(math.isInf(infinite_f64)); |
|||
debug.assert(math.isInf(infinite_f128)); |
|||
debug.assert(math.isPositiveInf(infinite_f16)); |
|||
debug.assert(math.isPositiveInf(infinite_f32)); |
|||
debug.assert(math.isPositiveInf(infinite_f64)); |
|||
debug.assert(math.isPositiveInf(infinite_f128)); |
|||
debug.assert(math.isNegativeInf(-infinite_f16)); |
|||
debug.assert(math.isNegativeInf(-infinite_f32)); |
|||
debug.assert(math.isNegativeInf(-infinite_f64)); |
|||
debug.assert(math.isNegativeInf(-infinite_f128)); |
|||
debug.assert(!math.isFinite(infinite_f16)); |
|||
debug.assert(!math.isFinite(infinite_f32)); |
|||
debug.assert(!math.isFinite(infinite_f64)); |
|||
// isFinite(f128) is not implemented. |
|||
//debug.assert(!math.isFinite(infinite_f128)); |
|||
}</lang> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |