aboutsummaryrefslogtreecommitdiff
path: root/lib/std/math.zig
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/math.zig')
-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;
}