diff options
| author | r00ster91 <r00ster91@proton.me> | 2022-10-03 19:52:39 +0200 |
|---|---|---|
| committer | r00ster91 <r00ster91@proton.me> | 2022-10-05 21:19:10 +0200 |
| commit | 654e0b6679f3436bacbf685223d6ab68f707a62f (patch) | |
| tree | 3d643918bf5ab0e1a0754eeca210ee63cdd452e4 /lib/std/math.zig | |
| parent | 34835bbbcfe81cc87e823d14dc9b25e698ad5edc (diff) | |
| download | zig-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.zig | 7 |
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), |
