From: Ian Jackson Date: Sun, 4 Oct 2020 18:58:17 +0000 (+0100) Subject: limb type X-Git-Tag: otter-0.2.0~757 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=171aa53fae565ba4a5e9b647b8b5488bb480f170;p=otter.git limb type Signed-off-by: Ian Jackson --- diff --git a/src/bigfloat.rs b/src/bigfloat.rs index 91a31777..9a6032db 100644 --- a/src/bigfloat.rs +++ b/src/bigfloat.rs @@ -7,13 +7,16 @@ enum Sign { Neg, Pos, } use Sign::*; type Sz = u16; -type Limb = [u16;3]; const CHARS_HEADER : usize = 5; const CHARS_PER_LIMB : usize = 15; pub use innards::Bigfloat; +#[repr(transparent)] +#[derive(Copy,Clone,Debug,Ord,PartialOrd,Eq,PartialEq)] +struct Limb (pub [u16;3]); + mod innards { use super::*; use std::mem::{self, align_of, size_of}; @@ -169,11 +172,11 @@ impl Bigfloat { Some(' ') => (), _ => None?, }; - limbs.push([ + limbs.push(Limb([ p.hex16_()?, p.hex16_()?, p.hex16()?, - ]); + ])); } if limbs.is_empty() { None? } Bigfloat::from_parts(sign, exp, &limbs) @@ -186,6 +189,15 @@ impl Bigfloat { write!(&mut s, "{}", self).unwrap(); s } + +/* + fn add(&self, v: u32) -> Bigfloat { + let (h, l) = self.as_parts(); + let l : Vec<_> = l.collect(); + + fn add_to_limb(&self, v: u32, ); + } +*/ } impl Display for Bigfloat { @@ -196,7 +208,7 @@ impl Display for Bigfloat { match h.sign { Pos => '+', Neg => '!', }, h.exp)?; for l in ls { - write!(f, " {:04x}_{:04x}_{:04x}", l[0], l[1], l[2])?; + write!(f, " {:04x}_{:04x}_{:04x}", l.0[0], l.0[1], l.0[2])?; } } }