Make core::num::dec2flt::strategy::grisu::Fp methods public.

The intent is to allow decimal-to-float parsing to use Fp in its fast path.
That code is added in a later commit.
This commit is contained in:
Robin Kruppe
2015-06-27 21:59:31 +02:00
parent e5d90d9840
commit b55806ca8f

View File

@@ -34,7 +34,7 @@ pub struct Fp {
impl Fp { impl Fp {
/// Returns a correctly rounded product of itself and `other`. /// Returns a correctly rounded product of itself and `other`.
fn mul(&self, other: &Fp) -> Fp { pub fn mul(&self, other: &Fp) -> Fp {
const MASK: u64 = 0xffffffff; const MASK: u64 = 0xffffffff;
let a = self.f >> 32; let a = self.f >> 32;
let b = self.f & MASK; let b = self.f & MASK;
@@ -51,7 +51,7 @@ impl Fp {
} }
/// Normalizes itself so that the resulting mantissa is at least `2^63`. /// Normalizes itself so that the resulting mantissa is at least `2^63`.
fn normalize(&self) -> Fp { pub fn normalize(&self) -> Fp {
let mut f = self.f; let mut f = self.f;
let mut e = self.e; let mut e = self.e;
if f >> (64 - 32) == 0 { f <<= 32; e -= 32; } if f >> (64 - 32) == 0 { f <<= 32; e -= 32; }
@@ -66,7 +66,7 @@ impl Fp {
/// Normalizes itself to have the shared exponent. /// Normalizes itself to have the shared exponent.
/// It can only decrease the exponent (and thus increase the mantissa). /// It can only decrease the exponent (and thus increase the mantissa).
fn normalize_to(&self, e: i16) -> Fp { pub fn normalize_to(&self, e: i16) -> Fp {
let edelta = self.e - e; let edelta = self.e - e;
assert!(edelta >= 0); assert!(edelta >= 0);
let edelta = edelta as usize; let edelta = edelta as usize;