VirtualBox

Ignore:
Timestamp:
Mar 31, 2023 11:02:33 AM (21 months ago)
Author:
vboxsync
Message:

VMM/IEM: Fix for extF80_ylog2x having argument x with negative exponent, bugref:9898

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/softfloat-3e/source/extF80_log2.c

    r96965 r99255  
    3737#include <iprt/x86.h>
    3838
     39/** The log2e constant as 128-bit floating point value.
     40 * base-10: 1.44269504088896340735992468100189185
     41 * base-16: 1.71547652b82fe1777d0ffda0d239
     42 * base-2 : 1.0111000101010100011101100101001010111000001011111110000101110111011111010000111111111101101000001101001000111001 */
     43const RTFLOAT128U g_r128Log2e = RTFLOAT128U_INIT_C(0, 0x71547652b82f, 0xe1777d0ffda0d239, 0x3fff);
     44
    3945extFloat80_t extF80_ylog2x(extFloat80_t y, extFloat80_t x SOFTFLOAT_STATE_DECL_COMMA)
    4046{
     
    4551    int_fast32_t expX;
    4652    uint_fast64_t sigX;
    47     extFloat80_t v;
     53    extFloat80_t v, log2e, log2m;
    4854
    4955    uX.f = x;
     
    5460    sigX  = uiX0;
    5561
     62    /* Linear approximation of log2x in the range [1, 2.0) (to be improved) */
    5663    uXM.s.signExp = RTFLOAT80U_EXP_BIAS;
    5764    uXM.s.signif = sigX;
    5865
    59     v = ui32_to_extF80(expX - RTFLOAT80U_EXP_BIAS - 1, pState);
    60     v = extF80_add(v, uXM.f, pState);
     66    v = i32_to_extF80(1, pState);
     67    v = extF80_sub(uXM.f, v, pState);
     68
     69    log2e = f128_to_extF80(*(float128_t *)&g_r128Log2e, pState);
     70    log2m = extF80_mul(v, log2e, pState);
     71
     72    v = i32_to_extF80(expX - RTFLOAT80U_EXP_BIAS, pState);
     73    v = extF80_add(v, log2m, pState);
    6174    v = extF80_mul(y, v, pState);
    6275
    6376    return v;
    6477}
    65 
    66 /** The log2e constant as 128-bit floating point value.
    67  * base-10: 1.44269504088896340735992468100189185
    68  * base-16: 1.71547652b82fe1777d0ffda0d239
    69  * base-2 : 1.0111000101010100011101100101001010111000001011111110000101110111011111010000111111111101101000001101001000111001 */
    70 const RTFLOAT128U g_r128Log2e = RTFLOAT128U_INIT_C(0, 0x71547652b82f, 0xe1777d0ffda0d239, 0x3fff);
    7178
    7279extFloat80_t extF80_ylog2xp1(extFloat80_t y, extFloat80_t x SOFTFLOAT_STATE_DECL_COMMA)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette