@@ -53,13 +53,13 @@ pub fn FixedPoint(comptime bits: comptime_int, comptime scaling: comptime_int) t
53
53
54
54
pub fn fromFloat (v : f32 ) F {
55
55
// std.debug.print("fromFloat({}, {d})\n", .{ Int, v });
56
- return .{ .raw = @floatToInt (Int , scaling * v ) };
56
+ return .{ .raw = @as (Int , @intFromFloat ( scaling * v ) ) };
57
57
}
58
58
59
59
pub fn toFloat (v : F , comptime T : type ) T {
60
60
// std.debug.print("toFloat({}, {})\n", .{ Int, v.raw });
61
61
_ = @typeInfo (T ).Float ;
62
- return @intToFloat (T , v .raw ) / scaling ;
62
+ return @as (T , @floatFromInt ( v .raw ) ) / scaling ;
63
63
}
64
64
65
65
pub fn fromInt (i : IntPart ) F {
@@ -68,7 +68,7 @@ pub fn FixedPoint(comptime bits: comptime_int, comptime scaling: comptime_int) t
68
68
69
69
pub fn toInt (f : F ) IntPart {
70
70
// std.debug.print("toInt({}, {})\n", .{ Int, f.raw });
71
- return @intCast (IntPart , @divTrunc (f .raw , scaling ));
71
+ return @as (IntPart , @intCast ( @ divTrunc (f .raw , scaling ) ));
72
72
}
73
73
74
74
// arithmetic operators:
@@ -82,11 +82,11 @@ pub fn FixedPoint(comptime bits: comptime_int, comptime scaling: comptime_int) t
82
82
}
83
83
84
84
pub fn mul (a : F , b : F ) F {
85
- return .{ .raw = @intCast (Int , scaleDown (@as (Int2 , a .raw ) * @as (Int2 , b .raw ))) };
85
+ return .{ .raw = @as (Int , @intCast ( scaleDown (@as (Int2 , a .raw ) * @as (Int2 , b .raw ) ))) };
86
86
}
87
87
88
88
pub fn div (a : F , b : F ) F {
89
- return .{ .raw = @intCast (Int , @divTrunc (scaleUp (a .raw ), b .raw )) };
89
+ return .{ .raw = @as (Int , @intCast ( @ divTrunc (scaleUp (a .raw ), b .raw ) )) };
90
90
}
91
91
92
92
pub fn mod (a : F , b : F ) F {
@@ -131,7 +131,7 @@ pub fn FixedPoint(comptime bits: comptime_int, comptime scaling: comptime_int) t
131
131
} else if (comptime std .mem .eql (u8 , fmt , "e" )) {
132
132
try std .fmt .formatFloatScientific (f .toFloat (f32 ), options , writer );
133
133
} else {
134
- @compileError (comptime std .fmt .comptimePrint ("Invalid fmt for FixedPoint({},{}): {{{s}}}" , .{ bits , scaling , fmt }));
134
+ @compileError (std .fmt .comptimePrint ("Invalid fmt for FixedPoint({},{}): {{{s}}}" , .{ bits , scaling , fmt }));
135
135
}
136
136
}
137
137
@@ -151,9 +151,9 @@ pub fn FixedPoint(comptime bits: comptime_int, comptime scaling: comptime_int) t
151
151
152
152
fn scaleDown (in : Int2 ) Int {
153
153
return if (is_pot )
154
- @intCast (Int , in >> precision_bits )
154
+ @as (Int , @intCast ( in >> precision_bits ) )
155
155
else
156
- @intCast (Int , @divTrunc (in , scaling ));
156
+ @as (Int , @intCast ( @ divTrunc (in , scaling ) ));
157
157
}
158
158
};
159
159
}
0 commit comments