diff options
| author | Loris Cro <kappaloris@gmail.com> | 2023-04-25 20:03:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-25 20:03:53 +0200 |
| commit | 015ea6fd6c0c0deacb42de237f737d208737e3ac (patch) | |
| tree | 33f5e2d3acacc24e63f259ce5485fee28243ed44 /lib/std/math.zig | |
| parent | a260fa8bf22b952e96b08c3f206756e1784ce870 (diff) | |
| parent | 8d88dcdc61c61e3410138f4402482131f5074a80 (diff) | |
| download | zig-015ea6fd6c0c0deacb42de237f737d208737e3ac.tar.gz zig-015ea6fd6c0c0deacb42de237f737d208737e3ac.zip | |
Merge branch 'master' into autodoc-pkg-mod
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 14c71a796f..02b737610c 100644 --- a/lib/std/math.zig +++ b/lib/std/math.zig @@ -782,7 +782,8 @@ fn testOverflow() !void { } /// Returns the absolute value of x, where x is a value of a signed integer type. -/// See also: `absCast` +/// Does not convert and returns a value of a signed integer type. +/// Use `absCast` if you want to convert the result and get an unsigned type. pub fn absInt(x: anytype) !@TypeOf(x) { const T = @TypeOf(x); return switch (@typeInfo(T)) { @@ -1015,8 +1016,8 @@ pub inline fn fabs(value: anytype) @TypeOf(value) { } /// Returns the absolute value of the integer parameter. -/// Result is an unsigned integer. -/// See also: `absInt` +/// Converts result type to unsigned if needed and returns a value of an unsigned integer type. +/// Use `absInt` if you want to keep your integer type signed. pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) { .ComptimeInt => comptime_int, .Int => |int_info| std.meta.Int(.unsigned, int_info.bits), |
