MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / wasm_nearest

Method wasm_nearest

crates/core/src/math.rs:141–158  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

139 }
140 #[inline]
141 fn wasm_nearest(self) -> f32 {
142 if self.is_nan() {
143 return f32::NAN;
144 }
145 #[cfg(feature = "std")]
146 if !cfg!(windows) && !cfg!(target_arch = "riscv64") {
147 return self.round_ties_even();
148 }
149 let round = libm::roundf(self);
150 if libm::fabsf(self - round) != 0.5 {
151 return round;
152 }
153 match round % 2.0 {
154 1.0 => libm::floorf(self),
155 -1.0 => libm::ceilf(self),
156 _ => round,
157 }
158 }
159 #[inline]
160 fn wasm_maximum(self, other: f32) -> f32 {
161 // FIXME: replace this with `a.maximum(b)` when rust-lang/rust#91079 is

Callers 6

fnearest32Method · 0.80
vnearest32x4Method · 0.80
vnearest64x2Method · 0.80
fnearest64Method · 0.80
nearest_f32Function · 0.80
nearest_f64Function · 0.80

Calls 5

floorfFunction · 0.85
ceilfFunction · 0.85
floorFunction · 0.85
ceilFunction · 0.85
is_nanMethod · 0.80

Tested by

no test coverage detected