I have discovered a relevant bug in Pokemon Showdown. Namely, the random factor was being rounded to nearest like most modifiers, but apparently it is not a modifier and should actually be rounded down.
This bug has been fixed, and you can test the new formula on the Pokemon Showdown main server right now.
I will be doing all I can to ensure a cartridge-accurate implementation of the damage formula.
Pokemon Showdown | Replay player | No, I am not impressed that you know that my name is Guangcong Luo. The PS website says "Copyright Guangcong Luo" at the bottom, ffs.