aboutsummaryrefslogtreecommitdiff
path: root/lib/std/math/float.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-08-28 10:49:31 -0700
committerGitHub <noreply@github.com>2024-08-28 10:49:31 -0700
commit31fef6f1103ea64a899729adea13b0ab9b66cb46 (patch)
tree31c13b06483af84cd0977be8de00d3539e3e3c4d /lib/std/math/float.zig
parent9a12905a2da045b0948f612583b526bca3a1b2f0 (diff)
parentaaa7e739831f39151a37c7beb08660f0fb6ae0ed (diff)
downloadzig-31fef6f1103ea64a899729adea13b0ab9b66cb46.tar.gz
zig-31fef6f1103ea64a899729adea13b0ab9b66cb46.zip
Merge pull request #21225 from mlugg/std-builtin-type
std: update `std.builtin.Type` fields to follow naming conventions
Diffstat (limited to 'lib/std/math/float.zig')
-rw-r--r--lib/std/math/float.zig20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/std/math/float.zig b/lib/std/math/float.zig
index 1d19fdc57c..a10332f863 100644
--- a/lib/std/math/float.zig
+++ b/lib/std/math/float.zig
@@ -6,21 +6,21 @@ const expectEqual = std.testing.expectEqual;
/// Creates a raw "1.0" mantissa for floating point type T. Used to dedupe f80 logic.
inline fn mantissaOne(comptime T: type) comptime_int {
- return if (@typeInfo(T).Float.bits == 80) 1 << floatFractionalBits(T) else 0;
+ return if (@typeInfo(T).float.bits == 80) 1 << floatFractionalBits(T) else 0;
}
/// Creates floating point type T from an unbiased exponent and raw mantissa.
inline fn reconstructFloat(comptime T: type, comptime exponent: comptime_int, comptime mantissa: comptime_int) T {
- const TBits = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } });
+ const TBits = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } });
const biased_exponent = @as(TBits, exponent + floatExponentMax(T));
return @as(T, @bitCast((biased_exponent << floatMantissaBits(T)) | @as(TBits, mantissa)));
}
/// Returns the number of bits in the exponent of floating point type T.
pub inline fn floatExponentBits(comptime T: type) comptime_int {
- comptime assert(@typeInfo(T) == .Float);
+ comptime assert(@typeInfo(T) == .float);
- return switch (@typeInfo(T).Float.bits) {
+ return switch (@typeInfo(T).float.bits) {
16 => 5,
32 => 8,
64 => 11,
@@ -32,9 +32,9 @@ pub inline fn floatExponentBits(comptime T: type) comptime_int {
/// Returns the number of bits in the mantissa of floating point type T.
pub inline fn floatMantissaBits(comptime T: type) comptime_int {
- comptime assert(@typeInfo(T) == .Float);
+ comptime assert(@typeInfo(T) == .float);
- return switch (@typeInfo(T).Float.bits) {
+ return switch (@typeInfo(T).float.bits) {
16 => 10,
32 => 23,
64 => 52,
@@ -46,12 +46,12 @@ pub inline fn floatMantissaBits(comptime T: type) comptime_int {
/// Returns the number of fractional bits in the mantissa of floating point type T.
pub inline fn floatFractionalBits(comptime T: type) comptime_int {
- comptime assert(@typeInfo(T) == .Float);
+ comptime assert(@typeInfo(T) == .float);
// standard IEEE floats have an implicit 0.m or 1.m integer part
// f80 is special and has an explicitly stored bit in the MSB
// this function corresponds to `MANT_DIG - 1' from C
- return switch (@typeInfo(T).Float.bits) {
+ return switch (@typeInfo(T).float.bits) {
16 => 10,
32 => 23,
64 => 52,
@@ -97,8 +97,8 @@ pub inline fn floatEps(comptime T: type) T {
/// Returns the local epsilon of floating point type T.
pub inline fn floatEpsAt(comptime T: type, x: T) T {
switch (@typeInfo(T)) {
- .Float => |F| {
- const U: type = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = F.bits } });
+ .float => |F| {
+ const U: type = @Type(.{ .int = .{ .signedness = .unsigned, .bits = F.bits } });
const u: U = @bitCast(x);
const y: T = @bitCast(u ^ 1);
return @abs(x - y);