chiark / gitweb /
fixes to bigfloat
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 4 Oct 2020 18:34:37 +0000 (19:34 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 4 Oct 2020 18:34:37 +0000 (19:34 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bigfloat.rs

index 2a44bf03e6257ce9836446763a9fdf1b5f5f34cf..e1a58ee1d3c5a9e6cab209cf2dbf3c5b8c265637 100644 (file)
@@ -1,10 +1,5 @@
 // See bigfloat.ts
 
-#![allow(unused_variables)]
-#![allow(dead_code)]
-#![allow(unused_mut)]
-#![allow(unused_imports)]
-
 use crate::imports::*;
 
 enum Sign { Pos, Neg, }
@@ -39,6 +34,7 @@ mod innards {
   }
 
   #[repr(C)]
+  #[allow(dead_code)] // this is for documentation purposes
   struct Repr {
     h: Header,
     limbs: [Limb],
@@ -86,6 +82,7 @@ mod innards {
       }
     }
 
+    #[allow(dead_code)] // xxx
     pub(in super)
     fn as_mut_limbs(&self) -> (&Header, &mut [Limb]) {
       unsafe {
@@ -162,7 +159,7 @@ impl Bigfloat {
       '!' => Neg,
       _ => None?,
     };
-    let exp = p.hex16();
+    let exp = p.hex16()?;
 
     let mut limbs = Vec::with_capacity(p.0.len() / CHARS_PER_LIMB);
     loop {
@@ -178,7 +175,7 @@ impl Bigfloat {
       ]);
     }
     if limbs.is_empty() { None? }
-    Bigfloat::from_parts(sign, 0, &limbs)
+    Bigfloat::from_parts(sign, exp, &limbs)
   }
 
   fn to_string(&self) -> String {