Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions crates/libm-test/src/f8_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use std::cmp::{self, Ordering};
use std::{fmt, ops};

use libm::support::hex_float::parse_any;

use crate::Float;

/// Sometimes verifying float logic is easiest when all values can quickly be checked exhaustively
Expand Down Expand Up @@ -499,5 +497,6 @@ impl fmt::LowerHex for f8 {
}

pub const fn hf8(s: &str) -> f8 {
f8(parse_any(s, 8, 3) as u8)
let Ok(bits) = libm::support::hex_float::parse_hex_exact(s, 8, 3) else { panic!() };
f8(bits as u8)
}
16 changes: 13 additions & 3 deletions src/math/support/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub enum Round {
}

/// IEEE 754 exception status flags.
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Status(u8);

impl Status {
Expand Down Expand Up @@ -90,16 +90,22 @@ impl Status {

/// True if `UNDERFLOW` is set.
#[cfg_attr(not(feature = "unstable-public-internals"), allow(dead_code))]
pub fn underflow(self) -> bool {
pub const fn underflow(self) -> bool {
self.0 & Self::UNDERFLOW.0 != 0
}

/// True if `OVERFLOW` is set.
#[cfg_attr(not(feature = "unstable-public-internals"), allow(dead_code))]
pub const fn overflow(self) -> bool {
self.0 & Self::OVERFLOW.0 != 0
}

pub fn set_underflow(&mut self, val: bool) {
self.set_flag(val, Self::UNDERFLOW);
}

/// True if `INEXACT` is set.
pub fn inexact(self) -> bool {
pub const fn inexact(self) -> bool {
self.0 & Self::INEXACT.0 != 0
}

Expand All @@ -114,4 +120,8 @@ impl Status {
self.0 &= !mask.0;
}
}

pub(crate) const fn with(self, rhs: Self) -> Self {
Self(self.0 | rhs.0)
}
}
Loading
Loading