mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-02 19:32:17 +00:00
f32FromParts and f64FromParts for repl
This commit is contained in:
parent
473b8ef2d3
commit
11998b9cc8
12 changed files with 48 additions and 4 deletions
|
@ -113,6 +113,8 @@ comptime {
|
|||
exportNumFn(num.greaterThanOrEqualU128, "greater_than_or_equal.u128");
|
||||
exportNumFn(num.f32ToParts, "f32_to_parts");
|
||||
exportNumFn(num.f64ToParts, "f64_to_parts");
|
||||
exportNumFn(num.f32FromParts, "f32_from_parts");
|
||||
exportNumFn(num.f64FromParts, "f64_from_parts");
|
||||
|
||||
inline for (INTEGERS, 0..) |T, i| {
|
||||
num.exportPow(T, ROC_BUILTINS ++ "." ++ NUM ++ ".pow_int.");
|
||||
|
|
|
@ -660,3 +660,11 @@ pub fn f64ToParts(self: f64) callconv(.C) F64Parts {
|
|||
.sign = u64Value >> 63 & 1 == 1,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn f32FromParts(parts: F32Parts) callconv(.C) f32 {
|
||||
return @as(f32, @bitCast(parts.fraction | (@as(u32, parts.exponent) << 23) | (@as(u32, @intFromBool(parts.sign)) << 31)));
|
||||
}
|
||||
|
||||
pub fn f64FromParts(parts: F64Parts) callconv(.C) f64 {
|
||||
return @as(f64, @bitCast(parts.fraction | (@as(u64, parts.exponent) << 52) | (@as(u64, @intFromBool(parts.sign)) << 63)));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue