MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / numeric_round

Function numeric_round

crates/gitql-std/src/number/mod.rs:184–194  ·  view source on GitHub ↗
(inputs: &[Box<dyn Value>])

Source from the content-addressed store, hash-verified

182}
183
184pub fn numeric_round(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
185 let number = inputs[0].as_float().unwrap();
186 let decimal_places = if inputs.len() == 2 {
187 inputs[1].as_int().unwrap()
188 } else {
189 0
190 };
191 let multiplier = 10_f64.powi(decimal_places.try_into().unwrap());
192 let result = (number * multiplier).round() / multiplier;
193 Box::new(FloatValue { value: result })
194}
195
196pub fn numeric_square(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
197 let int_value = inputs[0].as_int().unwrap();

Callers

nothing calls this directly

Calls 3

as_floatMethod · 0.80
as_intMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…