all: migrate code to new cast builtin syntax

Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
This commit is contained in:
mlugg
2023-06-22 18:46:56 +01:00
committed by Andrew Kelley
parent 447ca4e3ff
commit f26dda2117
651 changed files with 8967 additions and 9039 deletions

View File

@@ -32,7 +32,7 @@ pub fn BiasedFp(comptime T: type) type {
pub fn toFloat(self: Self, comptime FloatT: type, negative: bool) FloatT {
var word = self.f;
word |= @intCast(MantissaT, self.e) << std.math.floatMantissaBits(FloatT);
word |= @as(MantissaT, @intCast(self.e)) << std.math.floatMantissaBits(FloatT);
var f = floatFromUnsigned(FloatT, MantissaT, word);
if (negative) f = -f;
return f;
@@ -42,10 +42,10 @@ pub fn BiasedFp(comptime T: type) type {
pub fn floatFromUnsigned(comptime T: type, comptime MantissaT: type, v: MantissaT) T {
return switch (T) {
f16 => @bitCast(f16, @truncate(u16, v)),
f32 => @bitCast(f32, @truncate(u32, v)),
f64 => @bitCast(f64, @truncate(u64, v)),
f128 => @bitCast(f128, v),
f16 => @as(f16, @bitCast(@as(u16, @truncate(v)))),
f32 => @as(f32, @bitCast(@as(u32, @truncate(v)))),
f64 => @as(f64, @bitCast(@as(u64, @truncate(v)))),
f128 => @as(f128, @bitCast(v)),
else => unreachable,
};
}