diff --git a/src/hint_processor/uint256_utils.zig b/src/hint_processor/uint256_utils.zig index 063f4c2f..f678d536 100644 --- a/src/hint_processor/uint256_utils.zig +++ b/src/hint_processor/uint256_utils.zig @@ -355,12 +355,13 @@ pub fn uint256OffsetedUnsignedDivRem( // TODO: optimize use biguint instead of u512 const a_shifted = (@as(u512, a_high.toInteger()) << 128) + @as(u512, a_low.toInteger()); const div = (@as(u512, div_high.toInteger()) << 128) + @as(u512, div_low.toInteger()); + //a and div will always be positive numbers //Then, Rust div_rem equals Python divmod const quotient_remainder = try helper.divRem(u512, a_shifted, div); - const quotient = Uint256.fromFelt(Felt252.fromInt(u512, quotient_remainder[0])); - const remainder = Uint256.fromFelt(Felt252.fromInt(u512, quotient_remainder[1])); + const quotient = Uint256.split(u512, quotient_remainder[0]); + const remainder = Uint256.split(u512, quotient_remainder[1]); try quotient.insertFromVarName(allocator, "quotient", vm, ids_data, ap_tracking); try remainder.insertFromVarName(allocator, "remainder", vm, ids_data, ap_tracking); diff --git a/src/integration_tests.zig b/src/integration_tests.zig index f493be39..4db9540d 100644 --- a/src/integration_tests.zig +++ b/src/integration_tests.zig @@ -215,8 +215,7 @@ pub fn main() void { //TODO: hint uint384 not implemented // .{ .pathname = "cairo_programs/uint256_improvements.json", .layout = "all_cairo" }, .{ .pathname = "cairo_programs/uint256_integration_tests.json", .layout = "all_cairo" }, - // TODO: fix DiffAssertValues - // .{ .pathname = "cairo_programs/uint256.json", .layout = "all_cairo" }, + .{ .pathname = "cairo_programs/uint256.json", .layout = "all_cairo" }, // .{ .pathname = "cairo_programs/uint384_extension_test.json", .layout = "all_cairo" }, // .{ .pathname = "cairo_programs/uint384_extension.json", .layout = "all_cairo" }, diff --git a/src/math/fields/fields.zig b/src/math/fields/fields.zig index bf126096..35ee9e49 100644 --- a/src/math/fields/fields.zig +++ b/src/math/fields/fields.zig @@ -81,6 +81,10 @@ pub fn Field(comptime F: type, comptime modulo: u256) type { fe: F.MontgomeryDomainFieldElement, + pub fn format(self: Self, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { + return std.fmt.format(writer, "Felt({any})", .{self.toInteger()}); + } + /// Mask to apply to the highest limb to get the correct number of bits. pub fn mask(bits: usize) u64 { return switch (bits) {