aboutsummaryrefslogtreecommitdiff
path: root/lib/std/math.zig
diff options
context:
space:
mode:
authorLoris Cro <kappaloris@gmail.com>2023-04-25 20:03:53 +0200
committerGitHub <noreply@github.com>2023-04-25 20:03:53 +0200
commit015ea6fd6c0c0deacb42de237f737d208737e3ac (patch)
tree33f5e2d3acacc24e63f259ce5485fee28243ed44 /lib/std/math.zig
parenta260fa8bf22b952e96b08c3f206756e1784ce870 (diff)
parent8d88dcdc61c61e3410138f4402482131f5074a80 (diff)
downloadzig-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.zig7
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),