From e3d8d53d70c1ccc5d7b06cb51baca98cf81a8af6 Mon Sep 17 00:00:00 2001 From: Ryan Pitasky Date: Mon, 2 Sep 2024 15:37:02 -0400 Subject: [PATCH] add `shift` function --- src/float.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/float.rs b/src/float.rs index 0c79972..fd6e442 100644 --- a/src/float.rs +++ b/src/float.rs @@ -143,6 +143,14 @@ impl Float { Err(FloatError::Overflow) } } + + pub fn shift(&self, delta: i8) -> Float { + Float { + flags: self.flags, + mantissa: self.mantissa, + exponent: (self.exponent as i8).wrapping_add(delta) as u8 + } + } } impl Float {