diff --git a/doc/langref.html.in b/doc/langref.html.in index a084a57825712b5f88ce17ffc5e70ae66b4e02ea..9f32e05896e3eccf237f6388b79198f65c90a0b8 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -3582,12 +3582,10 @@ void do_a_thing(struct Foo *foo) { {#header_close#} {#header_open|Explicit Casts#} -
- Explicit casts are performed via {#link|Builtin Functions#}. - Some explicit casts are safe; some are not. - Some explicit casts perform language-level assertions; some do not. - Some explicit casts are no-ops at runtime; some are not. -
+Explicit casts are performed via {#link|Builtin Functions#}.
+Some explicit casts can violate type safety when used incorrectly.
+Some explicit casts perform language-level assertions.
+Some explicit casts are no-ops at runtime.
{#syntax#}@floatFromInt(int: anytype) anytype{#endsyntax#}
Converts an integer to the closest floating point representation. The return type is the inferred result type. - To convert the other way, use {#link|@intFromFloat#}. This operation is legal - for all values of all integer types. + To convert the other way, use {#link|@round#}, {#link|@floor#}, + {#link|@ceil#}, or {#link|@trunc#}. This operation is legal for all + values of all integer types.
{#header_close#} @@ -5135,14 +5134,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val {#header_open|@intFromFloat#}{#syntax#}@intFromFloat(float: anytype) anytype{#endsyntax#}
- - Converts the integer part of a floating point number to the inferred result type. -
-- If the integer part of the floating point number cannot fit in the destination type, - it invokes safety-checked {#link|Illegal Behavior#}. -
- {#see_also|@floatFromInt#} +Deprecated. Equivalent to {#link|@trunc#}.
+ {#see_also|@floatFromInt|@round|@floor|@ceil|@trunc#} {#header_close#} {#header_open|@intFromPtr#} @@ -5721,47 +5714,51 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val Supports {#link|Floats#}, {#link|Integers#} and {#link|Vectors#} of floats or integers. {#header_close#} + {#header_open|@floor#}{#syntax#}@floor(value: anytype) @TypeOf(value){#endsyntax#}
- - Returns the largest integral value not greater than the given floating point number. - Uses a dedicated hardware instruction when available. -
-- Supports {#link|Floats#} and {#link|Vectors#} of floats. -
+Returns the largest integral value not greater than the given floating point number. + Uses a dedicated hardware instruction when available.
+Supports {#link|Floats#} and {#link|Vectors#} of floats.
+When the inferred result type is an {#link|integer|Integers#}, + the integer part is extracted from the floored result. If that value + cannot fit in the destination type, it invokes safety-checked + {#link|Illegal Behavior#}.
{#header_close#} + {#header_open|@ceil#}{#syntax#}@ceil(value: anytype) @TypeOf(value){#endsyntax#}
- - Returns the smallest integral value not less than the given floating point number. - Uses a dedicated hardware instruction when available. -
-- Supports {#link|Floats#} and {#link|Vectors#} of floats. -
+Returns the smallest integral value not less than the given floating point number. + Uses a dedicated hardware instruction when available.
+Supports {#link|Floats#} and {#link|Vectors#} of floats.
+When the inferred result type is an {#link|integer|Integers#}, + the integer part is extracted from the ceiled result. If that value + cannot fit in the destination type, it invokes safety-checked + {#link|Illegal Behavior#}.
{#header_close#} + {#header_open|@trunc#}{#syntax#}@trunc(value: anytype) @TypeOf(value){#endsyntax#}
- - Rounds the given floating point number to an integer, towards zero. - Uses a dedicated hardware instruction when available. -
-- Supports {#link|Floats#} and {#link|Vectors#} of floats. -
+Rounds the given floating point number to an integer, towards zero. + Uses a dedicated hardware instruction when available.
+Supports {#link|Floats#} and {#link|Vectors#} of float parameters.
+When the inferred result type is an {#link|integer|Integers#}, + the integer part is extracted from the truncated result. If that value + cannot fit in the destination type, it invokes safety-checked + {#link|Illegal Behavior#}.
{#header_close#} + {#header_open|@round#}{#syntax#}@round(value: anytype) @TypeOf(value){#endsyntax#}
- - Rounds the given floating point number to the nearest integer. If two integers are equally close, rounds away from zero. - Uses a dedicated hardware instruction when available. -
+Rounds the given floating point number to the nearest integer. If two + integers are equally close, rounds away from zero. Uses a dedicated + hardware instruction when available.
{#code|test_round_builtin.zig#} - -- Supports {#link|Floats#} and {#link|Vectors#} of floats. -
+Supports {#link|Floats#} and {#link|Vectors#} of floats.
+When the inferred result type is an {#link|integer|Integers#}, + the integer part is extracted from the rounded result. If that value + cannot fit in the destination type, it invokes safety-checked + {#link|Illegal Behavior#}.
{#header_close#} {#header_open|@subWithOverflow#}