MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / fp_fclass_d

Function fp_fclass_d

crates/virtual-machine/src/cpu/alu.rs:748–764  ·  view source on GitHub ↗
(a: f64)

Source from the content-addressed store, hash-verified

746 let sign = bits >> 63 != 0;
747 if a.is_nan() {
748 1u64 << 9
749 } else if a.is_infinite() {
750 if sign { 1 << 0 } else { 1 << 7 }
751 } else if a == 0.0 {
752 if sign { 1 << 3 } else { 1 << 4 }
753 } else if (bits & 0x7FF0_0000_0000_0000) == 0 {
754 if sign { 1 << 2 } else { 1 << 5 }
755 } else if sign {
756 1 << 1
757 } else {
758 1 << 6
759 }
760}
761
762// --- Fused multiply-add (F extension), exact via f64 promotion ---
763// f32 FMA runs in f64: the product (<= 48 bits) and sum (<= 49 bits) fit exactly
764// in a 53-bit mantissa, so only the final rounding back to f32 is inexact.
765
766pub fn fp_fmadd_s(rs1: f32, rs2: f32, rs3: f32, rm: u8) -> (u64, u8) {
767 if rs1.is_nan() || rs2.is_nan() || rs3.is_nan() {

Callers 2

exec_fp_opFunction · 0.85
fp_fclass_infFunction · 0.85

Calls

no outgoing calls

Tested by 1

fp_fclass_infFunction · 0.68