diff options
| author | Shawn Landden <shawn@git.icu> | 2019-06-21 16:18:59 -0500 |
|---|---|---|
| committer | Shawn Landden <shawn@git.icu> | 2019-06-22 14:34:34 -0500 |
| commit | 71e014caecaa54fdd8a0516710d2d9597da41398 (patch) | |
| tree | 4cfc85ed66ba9aec49e3f672a80c39b98e598177 /doc | |
| parent | ebde2ff899c16612c7ff58df61f3946be47c51c8 (diff) | |
| download | zig-71e014caecaa54fdd8a0516710d2d9597da41398.tar.gz zig-71e014caecaa54fdd8a0516710d2d9597da41398.zip | |
stage1: add @sin @cos @exp @exp2 @ln @log2 @log10 @fabs @floor @ceil @trunc @round
and expand @sqrt
This revealed that the accuracy of ln is not as good as the current algorithm in
musl and glibc, and should be ported again.
v2: actually include tests
v3: fix reversal of in and out arguments on f128M_sqrt()
add test for @sqrt on comptime_float
do not include @nearbyInt() until it works on all targets.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/langref.html.in | 85 |
1 files changed, 83 insertions, 2 deletions
diff --git a/doc/langref.html.in b/doc/langref.html.in index 9b95946256..30fe9a3648 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -7354,10 +7354,91 @@ test "@setRuntimeSafety" { <pre>{#syntax#}@sqrt(comptime T: type, value: T) T{#endsyntax#}</pre> <p> Performs the square root of a floating point number. Uses a dedicated hardware instruction - when available. Currently only supports f32 and f64 at runtime. f128 at runtime is TODO. + when available. Supports f16, f32, f64, and f128, as well as vectors. </p> + {#header_close#} + {#header_open|@sin#} + <pre>{#syntax#}@sin(comptime T: type, value: T) T{#endsyntax#}</pre> + <p> + Sine trigometric function on a floating point number. Uses a dedicated hardware instruction + when available. Currently supports f32 and f64. + </p> + {#header_close#} + {#header_open|@cos#} + <pre>{#syntax#}@cos(comptime T: type, value: T) T{#endsyntax#}</pre> + <p> + Cosine trigometric function on a floating point number. Uses a dedicated hardware instruction + when available. Currently supports f32 and f64. + </p> + {#header_close#} + {#header_open|@exp#} + <pre>{#syntax#}@exp(comptime T: type, value: T) T{#endsyntax#}</pre> + <p> + Base-e exponential function on a floating point number. Uses a dedicated hardware instruction + when available. Currently supports f32 and f64. + </p> + {#header_close#} + {#header_open|@exp2#} + <pre>{#syntax#}@exp2(comptime T: type, value: T) T{#endsyntax#}</pre> + <p> + Base-2 exponential function on a floating point number. Uses a dedicated hardware instruction + when available. Currently supports f32 and f64. + </p> + {#header_close#} + {#header_open|@ln#} + <pre>{#syntax#}@ln(comptime T: type, value: T) T{#endsyntax#}</pre> + <p> + Returns the natural logarithm of a floating point number. Uses a dedicated hardware instruction + when available. Currently supports f32 and f64. + </p> + {#header_close#} + {#header_open|@log2#} + <pre>{#syntax#}@log2(comptime T: type, value: T) T{#endsyntax#}</pre> + <p> + Returns the logarithm to the base 2 of a floating point number. Uses a dedicated hardware instruction + when available. Currently supports f32 and f64. + </p> + {#header_close#} + {#header_open|@log10#} + <pre>{#syntax#}@log10(comptime T: type, value: T) T{#endsyntax#}</pre> + <p> + Returns the logarithm to the base 10 of a floating point number. Uses a dedicated hardware instruction + when available. Currently supports f32 and f64. + </p> + {#header_close#} + {#header_open|@fabs#} + <pre>{#syntax#}@fabs(comptime T: type, value: T) T{#endsyntax#}</pre> + <p> + Returns the absolute value of a floating point number. Uses a dedicated hardware instruction + when available. Currently supports f32 and f64. + </p> + {#header_close#} + {#header_open|@floor#} + <pre>{#syntax#}@floor(comptime T: type, value: T) T{#endsyntax#}</pre> + <p> + Returns the largest integral value not greater than the given floating point number. Uses a dedicated hardware instruction + when available. Currently supports f32 and f64. + </p> + {#header_close#} + {#header_open|@ceil#} + <pre>{#syntax#}@ceil(comptime T: type, value: T) T{#endsyntax#}</pre> + <p> + Returns the largest integral value not less than the given floating point number. Uses a dedicated hardware instruction + when available. Currently supports f32 and f64. + </p> + {#header_close#} + {#header_open|@trunc#} + <pre>{#syntax#}@trunc(comptime T: type, value: T) T{#endsyntax#}</pre> + <p> + Rounds the given floating point number to an integer, towards zero. Uses a dedicated hardware instruction + when available. Currently supports f32 and f64. + </p> + {#header_close#} + {#header_open|@round#} + <pre>{#syntax#}@round(comptime T: type, value: T) T{#endsyntax#}</pre> <p> - This is a low-level intrinsic. Most code can use {#syntax#}std.math.sqrt{#endsyntax#} instead. + Rounds the given floating point number to an integer, away from zero. Uses a dedicated hardware instruction + when available. Currently supports f32 and f64. </p> {#header_close#} |
