From: Ian Jackson Date: Sun, 4 Oct 2020 19:04:11 +0000 (+0100) Subject: into and from limb X-Git-Tag: otter-0.2.0~756 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=67e97a0fd3cb5e32b0062365007a6264a113da47;p=otter.git into and from limb Signed-off-by: Ian Jackson --- diff --git a/src/bigfloat.rs b/src/bigfloat.rs index 9a6032db..aa7bca34 100644 --- a/src/bigfloat.rs +++ b/src/bigfloat.rs @@ -122,6 +122,23 @@ mod innards { } } + +impl From for Limb { + fn from(u: u64) -> Limb { + assert_eq!(0, u >> 48); + Limb([ ((u >> 32) & 0xffff) as u16, + ((u >> 16) & 0xffff) as u16, + ((u >> 0) & 0xffff) as u16 ]) + } +} +impl From for u64 { + fn from(l: Limb) -> u64 { + ((l.0[0] as u64) << 32) | + ((l.0[1] as u64) << 16) | + ((l.0[2] as u64) << 0) + } +} + /*/ impl Bigfloat { fn from_parts(sign: Sign, exp: Sz, limbs: &[Limb]) {