493: if (Loperation) {
494:             // MIN_L_DIGIT_NUMBER is equal to BASE ** (MAX_L_DIGITS - 1).
495:             // We avoid losing the lsd this way, but we could get 1 extra digit
496:             rMan = Uint512.div512x256(r0, r1, MIN_L_DIGIT_NUMBER);
497:             assembly {
498:                 rExp := add(rExp, MAX_DIGITS_L_MINUS_1)
499:                 let hasExtraDigit := gt(rMan, MAX_L_DIGIT_NUMBER)
500:@>               let maxExp := sub(sub(add(ZERO_OFFSET, MAXIMUM_EXPONENT), DIGIT_DIFF_L_M), hasExtraDigit)
501:@>               Loperation := gt(rExp, maxExp)
...
518: } else {
519:             assembly {
520:                 // multiplication between 2 numbers with k digits can result in a number between 2*k - 1 and 2*k digits
521:                 // we check first if rMan is a 2k-digit number
522:                 let is76digit := gt(rMan, MAX_75_DIGIT_NUMBER)
523:@>               let maxExp := add(
524:@>                   sub(sub(add(ZERO_OFFSET, MAXIMUM_EXPONENT), DIGIT_DIFF_L_M), DIGIT_DIFF_76_L),
525:@>                   iszero(is76digit)
526:@>               )
527:@>               Loperation := gt(rExp, maxExp)
...
553: if Loperation {
554:                 r := or(r, MANTISSA_L_FLAG_MASK)
555:             }
pragma solidity ^0.8.24;

import "forge-std/Test.sol";
import "src/Float128.sol";
import {Ln} from "src/Ln.sol";
import {Math} from "src/Math.sol";
import {packedFloat} from "src/Types.sol";

contract ForteTest is Test {
    using Float128 for packedFloat;

    function testM03POC() external {
        int256 aMan = 100000000000000000000000000000000000000000000000000000000000000000000000;
        int256 aExp = -53;

        int256 bMan = 999999999999999999999999999999999999999999999999999999999999999999999999;
        int256 bExp = -56;

        packedFloat a = Float128.toPackedFloat(aMan, aExp);
        packedFloat b = Float128.toPackedFloat(bMan, bExp);
        packedFloat left = a.add(b).sub(b);
        packedFloat right = a.sub(b).add(b);
        _debug("a", a);
        _debug("b", b);
        _debug("left", left);
        _debug("right", right);
        (int256 lMan, int256 lExp) = left.decode();
        (int256 rMan, int256 rExp) = right.decode();
        assertEq(lExp, rExp, "exp mismatch");
        assertEq(rMan - lMan, 9, "ULP != 9");
    }

    function _debug(string memory message, packedFloat float) internal {
        console.log(message);
        _debug(float);
    }

    function _debug(packedFloat float) internal {
        (int256 mantissa, int256 exponent) = float.decode();
        emit log_named_uint("\tunwrapped", packedFloat.unwrap(float));
        emit log_named_int("\tmantissa", mantissa);
        emit log_named_uint(
            "\tmantissa digits", Float128.findNumberOfDigits(packedFloat.unwrap(float) & Float128.MANTISSA_MASK)
        );
        emit log_named_int("\texponent", exponent);
    }
}
Logs:
  a
        unwrapped: 57525106735054637002573000029187941038311220714476402038523254701685114667008
        mantissa: 100000000000000000000000000000000000000000000000000000000000000000000000
        mantissa digits: 72
        exponent: -53
  b
        unwrapped: 57504804570277296390618000459179026016121290907713894611025795427269603229695
        mantissa: 999999999999999999999999999999999999999999999999999999999999999999999999
        mantissa digits: 72
        exponent: -56
  left
        unwrapped: 57754696853475826965418828704284520445468793621070232503079063507853155237878
        mantissa: 99999999999999999999999999999999999990
        mantissa digits: 38
        exponent: -20
  right
        unwrapped: 57754696853475826965418828704284520445468793621070232503079063507853155237887
        mantissa: 99999999999999999999999999999999999999
        mantissa digits: 38
        exponent: -20
