MCPcopy Create free account
hub / github.com/NotAShelf/microfetch / round_f64

Function round_f64

crates/lib/src/system.rs:131–149  ·  view source on GitHub ↗
(x: f64)

Source from the content-addressed store, hash-verified

129 clippy::cast_sign_loss
130)]
131fn round_f64(x: f64) -> f64 {
132 if x >= 0.0 {
133 let int_part = x as u64 as f64;
134 let frac = x - int_part;
135 if frac >= 0.5 {
136 int_part + 1.0
137 } else {
138 int_part
139 }
140 } else {
141 let int_part = (-x) as u64 as f64;
142 let frac = -x - int_part;
143 if frac >= 0.5 {
144 -(int_part + 1.0)
145 } else {
146 -int_part
147 }
148 }
149}
150
151/// Write a u64 to string
152pub fn write_u64(s: &mut String, mut n: u64) {

Callers 1

get_memory_usageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected