aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorzooster <r00ster91@proton.me>2022-09-30 16:45:37 +0200
committerVeikka Tuominen <git@vexu.eu>2022-10-01 13:46:20 +0300
commit91b05ad473b4d16e9a50a83f2655599ce177e767 (patch)
treeb02f24e1762977bcd2be9aa3b6a805552ebcdb38 /lib
parent34835bbbcfe81cc87e823d14dc9b25e698ad5edc (diff)
downloadzig-91b05ad473b4d16e9a50a83f2655599ce177e767.tar.gz
zig-91b05ad473b4d16e9a50a83f2655599ce177e767.zip
std.math: allow comptime_float for radiansToDegrees and degreesToRadians
And some other minor things.
Diffstat (limited to 'lib')
-rw-r--r--lib/std/math.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/std/math.zig b/lib/std/math.zig
index a69a6f428c..18c8f555d4 100644
--- a/lib/std/math.zig
+++ b/lib/std/math.zig
@@ -285,10 +285,10 @@ pub inline fn tan(value: anytype) @TypeOf(value) {
return @tan(value);
}
-// Convert an angle in radians to degrees. T must be a float type.
+/// Converts an angle in radians to degrees. T must be a float type.
pub fn radiansToDegrees(comptime T: type, angle_in_radians: T) T {
- if (@typeInfo(T) != .Float)
- @compileError("T must be a float type.");
+ if (@typeInfo(T) != .Float and @typeInfo(T) != .ComptimeFloat)
+ @compileError("T must be a float type");
return angle_in_radians * 180.0 / pi;
}
@@ -300,10 +300,10 @@ test "radiansToDegrees" {
try std.testing.expectApproxEqAbs(@as(f32, 360), radiansToDegrees(f32, 2.0 * pi), 1e-6);
}
-// Convert an angle in degrees to radians. T must be a float type.
+/// Converts an angle in degrees to radians. T must be a float type.
pub fn degreesToRadians(comptime T: type, angle_in_degrees: T) T {
- if (@typeInfo(T) != .Float)
- @compileError("T must be a float type.");
+ if (@typeInfo(T) != .Float and @typeInfo(T) != .ComptimeFloat)
+ @compileError("T must be a float type");
return angle_in_degrees * pi / 180.0;
}