I'm currently mostly seeing this affect scripts that employ BatBrain. Since monsters' chance to hit can drop VERY low at times, it occasionally goes to scientific notation and the computation fails...
Okay, so I'm sick of looking at BatBrain, but there's floating point precision problems throughout this library. Whilst your issue with the handling of floats in expressions may be a valid one, it's arising out of accuracy issues deep within BatBrain and/or Zlib, KoLmafia handling these floats correctly isn't going to fix that.
The issue you're experiencing specifically comes out of monster_stat("hp") in BatBrain.ash, this line here:
PHP:
case "hp": return adj.dmg[$element[none]] + max(1.0, (m == last_monster() ? monster_hp() : monster_hp(m)));
For whatever whack reason, adj.dmg[$element[none]] seems to return a number with "too much precision", by that I mean the number has too many decimal places. From what I can tell, this comes out of some
float accuracy errors somewhere, so instead of getting a value like -1 for adj.dmg[$element[none]], you get -0.99999994. To make things simple, let's say I'm fighting a monster with 1hp, the adjusted HP value becomes (1.0-0.99999994) which you might think is 0.00000006, but due to our old friend float, this actually becomes 5.9604645E-8. Much later down the track, modifier_eval() eventually gets called on this number, guess what happens?
Code:
> ash modifier_eval("5.9604645E-8")
Expression syntax error for 'modifier_eval()': expected end, found E-8
Returned: 5.9604645
So now you've gone from a number which for all intents and purposes should equal 0, to a number which is closer to 6. Henceforth, all the calculations done on this number are going to be wrong. I stopped reading through the logs shortly after this point, but 5.9604645 appears later on down the track in reference to "mp".
Code:
[NORMAL] <- 0.0
Eval: fact
Set: 0.33
AREF: record advevent
Key #1: "mp"
[NORMAL] <- "mp"
AREF <- 5.9604645
Operator: *
Operand 1: 5.9604645
[NORMAL] <- 5.9604645
Operand 2: 0.33
[NORMAL] <- 0.33
<- 1.9669534
ASET: 1.9669534
[NORMAL] <- 1.9669534
If you want to have some fun, get on a decent level account, go to Noob Cave, turn debugging on and try to kill a crate with a combat script that uses BatBrain.