Add Num.withDecimalPoint

This commit is contained in:
Fabian Schmalzried 2024-03-15 10:43:05 +01:00
parent 9c664172dd
commit 64e9899cad
No known key found for this signature in database
GPG key ID: D691D5DA4CEF42E7
12 changed files with 34 additions and 13 deletions

View file

@ -226,6 +226,10 @@ pub const RocDec = extern struct {
return self.num;
}
pub fn fromI128(num: i128) RocDec {
return .{ .num = num };
}
pub fn eq(self: RocDec, other: RocDec) bool {
return self.num == other.num;
}
@ -1475,6 +1479,10 @@ pub fn toI128(arg: RocDec) callconv(.C) i128 {
return @call(.always_inline, RocDec.toI128, .{arg});
}
pub fn fromI128(arg: i128) callconv(.C) RocDec {
return @call(.always_inline, RocDec.fromI128, .{arg});
}
pub fn eqC(arg1: RocDec, arg2: RocDec) callconv(.C) bool {
return @call(.always_inline, RocDec.eq, .{ arg1, arg2 });
}

View file

@ -49,6 +49,7 @@ comptime {
exportDecFn(dec.tanC, "tan");
exportDecFn(dec.toF64, "to_f64");
exportDecFn(dec.toI128, "to_i128");
exportDecFn(dec.fromI128, "from_i128");
exportDecFn(dec.toStr, "to_str");
inline for (INTEGERS) |T| {