Skip to content

Commit

Permalink
Move Sub for DiyFp out of diyfp macro
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 13, 2021
1 parent 7e061ca commit 6851ecc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
25 changes: 14 additions & 11 deletions src/diyfp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// License for the specific language governing permissions and limitations under
// the License.

use core::ops::Mul;
use core::ops::{Mul, Sub};

#[derive(Copy, Clone, Debug)]
pub struct DiyFp<F, E> {
Expand All @@ -40,6 +40,19 @@ impl<F, E> DiyFp<F, E> {
}
}

impl<F, E> Sub for DiyFp<F, E>
where
F: Sub<F, Output = F>,
{
type Output = Self;
fn sub(self, rhs: Self) -> Self {
DiyFp {
f: self.f - rhs.f,
e: self.e,
}
}
}

impl Mul for DiyFp<u32, i32> {
type Output = Self;
fn mul(self, rhs: Self) -> Self {
Expand Down Expand Up @@ -210,16 +223,6 @@ macro_rules! diyfp {
}
}

impl Sub for DiyFp {
type Output = Self;
fn sub(self, rhs: Self) -> Self {
DiyFp {
f: self.f - rhs.f,
e: self.e,
}
}
}

/*
inline DiyFp GetCachedPower(int e, int* K) {
//int k = static_cast<int>(ceil((-61 - e) * 0.30102999566398114)) + 374;
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ mod diyfp;
mod dtoa;

use core::mem::{self, MaybeUninit};
use core::ops::Sub;
use core::ptr;
use core::slice;
use core::str;
Expand Down

0 comments on commit 6851ecc

Please sign in to comment.