VirtualBox

Ignore:
Timestamp:
Mar 10, 2024 1:36:04 PM (11 months ago)
Author:
vboxsync
Message:

ValidationKit/bootsectors: fix my buggy modulo math, bugref:9898

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-3.c32

    r103748 r103749  
    605605     * This piece-wise modulus operation is vastly faster
    606606     * than openwatcom's built-in 64-div-32 routine!
     607     *
     608     * Math:    high longword's effect % INT32_MAX
     609     *       = (high longword * 2^32) % INT32_MAX
     610     *       = (high longword * (2^32 - 2 * INT32_MAX)) % INT32_MAX
     611     *       = (high longword * 2) % INT32_MAX
     612     *       = (high longword * 2), since uProduct is a 'small' 64-bit value
     613     *              (high longword of a 32-bit-value * 16807, a 15-bit value)
    607614     */
    608     uHiMod = (uProduct.au32[0] * 2) % INT32_MAX;
    609     uLoMod = (uProduct.au32[1] & 0xFFFFFFFF) % INT32_MAX;
     615    uHiMod = uProduct.au32[1] * 2;
     616    uLoMod = uProduct.au32[0] % INT32_MAX;
    610617    s_uSeedMemory = (uHiMod + uLoMod) % INT32_MAX;
    611618    return s_uSeedMemory;
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