(&self, v: Val)
| 569 | } |
| 570 | |
| 571 | pub(crate) fn to_f64_coerce(&self, v: Val) -> Result<f64, VmErr> { |
| 572 | if v.is_int() { return Ok(v.as_int() as f64); } |
| 573 | if v.is_float() { return Ok(v.as_float()); } |
| 574 | if v.is_bool() { return Ok(v.as_bool() as i64 as f64); } |
| 575 | if v.is_heap() && let HeapObj::LongInt(i) = self.heap.get(v) { return Ok(*i as f64); } |
| 576 | Err(cold_type("numeric operand required")) |
| 577 | } |
| 578 | |
| 579 | /* Wrap an i128 into the narrowest Val: None->Overflow, 47-bit->inline, else LongInt. */ |
| 580 | #[inline] |
no test coverage detected