# Unwrapping while equating inside the eq function fails to account for the set L_MATISSA_FLAG

Float128.eq compares raw packed uint bit patterns, so two numerically equal floats with different mantissa sizes (M vs L flag) compare unequal, breaking equality logic.

- Payout: Contest reward
- Severity: high
- Program: Forte
- Credited: YouCrossTheLineAlfie
- Disclosed: 2025-04-29
- Write-up quality: 6/10
- Original: https://code4rena.com/reports/2025-04-forte-float128-solidity-library#h-04
- Library page: https://bugbountylibrary.com/r/c4%3A2025-04-forte-float128-solidity-library%3AH-04
- Tags: domain:web3 impact:integrity kind:contest platform:code4rena sev:high tech:solidity technique:source-review vuln:accounting-error

**Target:** Float128 fixed-point math library (packedFloat eq)
**Root cause:** eq unwraps packedFloat to uint and compares raw bit patterns; the L_MANTISSA_FLAG bit and differing mantissa/exponent encodings make numerically equal values have different bit patterns.
**Steps:**
1. Call `Float128.toPackedFloat(100000000000000000000000000000000000000000000000000000000000000000000000, -71)` -> packed1 (L mantissa, flag set)
2. Call `Float128.toPackedFloat(1, 0)` -> packed2 (M mantissa)
3. Both decode to value 1 (mantissa 1e71 exp -71 vs mantissa 1e37 exp -37)
4. `Float128.eq(packed1, packed2)` returns false despite equal values
**How found:** Code reading of eq's raw unwrap comparison against documented dual mantissa sizes (M:38, L:72 digits) and the L_MANTISSA_FLAG bit layout.
**Insight:** When a fixed-point type packs a size/flag bit into the same word as the value, any equality or hashing that compares raw words is wrong; check eq/hash/compare functions for normalization against the flag bit.
