MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / require_float

Function require_float

compiler/src/modules/vm/handlers/format.rs:262–268  ·  view source on GitHub ↗
(v: Val, heap: &HeapPool)

Source from the content-addressed store, hash-verified

260}
261
262fn require_float(v: Val, heap: &HeapPool) -> Result<f64, &'static str> {
263 if v.is_float() { return Ok(v.as_float()); }
264 if v.is_int() { return Ok(v.as_int() as f64); }
265 if v.is_bool() { return Ok(v.as_bool() as i64 as f64); }
266 if v.is_heap() && let HeapObj::LongInt(i) = heap.get(v) { return Ok(*i as f64); }
267 Err("format spec requires a number")
268}
269
270fn int_to_decimal_parts(v: Val, heap: &HeapPool) -> Result<(bool, String), &'static str> {
271 if v.is_int() {

Callers 2

format_percentFunction · 0.85
format_floatFunction · 0.85

Calls 8

is_floatMethod · 0.80
as_floatMethod · 0.80
is_intMethod · 0.80
as_intMethod · 0.80
is_boolMethod · 0.80
as_boolMethod · 0.80
is_heapMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected