mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Add Num.withDecimalPoint
This commit is contained in:
parent
9c664172dd
commit
64e9899cad
12 changed files with 34 additions and 13 deletions
|
@ -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 });
|
||||
}
|
||||
|
|
|
@ -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| {
|
||||
|
|
|
@ -151,7 +151,7 @@ interface Num
|
|||
toF64,
|
||||
toF64Checked,
|
||||
withoutDecimalPoint,
|
||||
# withDecimalPoint
|
||||
withDecimalPoint
|
||||
]
|
||||
imports [
|
||||
Bool.{ Bool },
|
||||
|
@ -1414,4 +1414,4 @@ toF64Checked : Num * -> Result F64 [OutOfBounds]
|
|||
withoutDecimalPoint : Dec -> I128
|
||||
|
||||
## Turns a [I128] into the coresponding [Dec], effectifely addoing the decimal point.
|
||||
#withDecimalPoint : I128 -> Dec
|
||||
withDecimalPoint : I128 -> Dec
|
|
@ -415,6 +415,7 @@ pub const DEC_SUB_SATURATED: &str = "roc_builtins.dec.sub_saturated";
|
|||
pub const DEC_SUB_WITH_OVERFLOW: &str = "roc_builtins.dec.sub_with_overflow";
|
||||
pub const DEC_TAN: &str = "roc_builtins.dec.tan";
|
||||
pub const DEC_TO_I128: &str = "roc_builtins.dec.to_i128";
|
||||
pub const DEC_FROM_I128: &str = "roc_builtins.dec.from_i128";
|
||||
pub const DEC_TO_STR: &str = "roc_builtins.dec.to_str";
|
||||
pub const DEC_ROUND: IntrinsicName = int_intrinsic!("roc_builtins.dec.round");
|
||||
pub const DEC_FLOOR: IntrinsicName = int_intrinsic!("roc_builtins.dec.floor");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue