authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-23 15:25:38-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-23 15:25:38-04:00
log55cb9ef138c7cf0a23e7f852a82884612a3ca663
tree95bdc6b98d63f8c888701b6e4f5b48ded95e334d
parent3e9697bb35267973554155cedc2e593bd4519dd8
signaturelock-open Commit is signed but in an unrecognized format.

docs: clarify NaN, inf, -inf

closes #2089

1 files changed, 18 insertions(+), 2 deletions(-)

doc/langref.html.in+18-2
......@@ -729,8 +729,13 @@ fn divide(a: i32, b: i32) i32 {
729729 </ul>
730730 {#header_open|Float Literals#}
731731 <p>
732 Float literals have type {#syntax#}comptime_float{#endsyntax#} which is guaranteed to hold at least all possible values
733 that the largest other floating point type can hold. Float literals {#link|implicitly cast|Implicit Casts#} to any other type.
732 Float literals have type {#syntax#}comptime_float{#endsyntax#} which is guaranteed to have
733 the same precision and operations of the largest other floating point type, which is
734 {#syntax#}f128{#endsyntax#}.
735 </p>
736 <p>
737 Float literals {#link|implicitly cast|Implicit Casts#} to any floating point type,
738 and to any {#link|integer|Integers#} type when there is no fractional component.
734739 </p>
735740 {#code_begin|syntax#}
736741const floating_point = 123.0E+77;
......@@ -740,6 +745,17 @@ const yet_another = 123.0e+77;
740745const hex_floating_point = 0x103.70p-5;
741746const another_hex_float = 0x103.70;
742747const yet_another_hex_float = 0x103.70P-5;
748 {#code_end#}
749 <p>
750 There is no syntax for NaN, infinity, or negative infinity. For these special values,
751 one must use the standard library:
752 </p>
753 {#code_begin|syntax#}
754const std = @import("std");
755
756const inf = std.math.inf(f32);
757const negative_inf = -std.math.inf(f64);
758const nan = std.math.nan(f128);
743759 {#code_end#}
744760 {#header_close#}
745761 {#header_open|Floating Point Operations#}