aboutsummaryrefslogtreecommitdiff
path: root/lib/std/math.zig
diff options
context:
space:
mode:
authorr00ster91 <r00ster91@proton.me>2022-10-03 19:52:39 +0200
committerr00ster91 <r00ster91@proton.me>2022-10-05 21:19:10 +0200
commit654e0b6679f3436bacbf685223d6ab68f707a62f (patch)
tree3d643918bf5ab0e1a0754eeca210ee63cdd452e4 /lib/std/math.zig
parent34835bbbcfe81cc87e823d14dc9b25e698ad5edc (diff)
downloadzig-654e0b6679f3436bacbf685223d6ab68f707a62f.tar.gz
zig-654e0b6679f3436bacbf685223d6ab68f707a62f.zip
fix(text): hyphenation and other fixes
Diffstat (limited to 'lib/std/math.zig')
-rw-r--r--lib/std/math.zig7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/std/math.zig b/lib/std/math.zig
index a69a6f428c..a4a5da83d1 100644
--- a/lib/std/math.zig
+++ b/lib/std/math.zig
@@ -762,14 +762,14 @@ fn testOverflow() !void {
try testing.expect((shlExact(i32, 0b11, 4) catch unreachable) == 0b110000);
}
-/// Returns the absolute value of x, where x is a value of an integer
-/// type.
+/// Returns the absolute value of x, where x is a value of a signed integer type.
+/// See also: `absCast`
pub fn absInt(x: anytype) !@TypeOf(x) {
const T = @TypeOf(x);
comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt
comptime assert(@typeInfo(T).Int.signedness == .signed); // must pass a signed integer to absInt
- if (x == minInt(@TypeOf(x))) {
+ if (x == minInt(T)) {
return error.Overflow;
} else {
@setRuntimeSafety(false);
@@ -977,6 +977,7 @@ pub inline fn fabs(value: anytype) @TypeOf(value) {
/// Returns the absolute value of the integer parameter.
/// Result is an unsigned integer.
+/// See also: `absInt`
pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {
.ComptimeInt => comptime_int,
.Int => |int_info| std.meta.Int(.unsigned, int_info.bits),