Beyond20
Beyond20 copied to clipboard
Using "add tiebreaker to initiative roll" should round extra floating point digits
Using "add tiebreaker to initiative roll" with Foundry VTT, on occasion the initiative is displayed in Foundry with extra digits in the decimal (e.g. 7.1400000000001)
could this be truncated, or rounded to 2 decimal points?
That's a purely cosmetic bug that has been around forever. It doesn't hurt anything.
It already is truncated to 2 decimal points:
The issue is javascript having those kinds of issues so that if you do 5 + 2.14
it gives 7.14000000000001
because of floating point precision in the javascript engine, because that's the closest value it can get to 7.14 which is an impossible value to hold in memory in the language.
Yes, it's stupid and infuriating and people keep facepalming about this.
toFixed returns a string, so is initiative being turned back into a float again before being output in the html? Seems like it needs another toFixed(2) when rendering the output.
toFixed returns a string, so is initiative being turned back into a float again before being output in the html? Seems like it needs another toFixed(2) when rendering the output.
yes, we make that into a string, something like 1d20 + 2.14
which is then rolled within Foundry. The roll's total then becomes what you've seen.
We can't toFixed(2)
when rendering the output otherwise every other roll would appear with .00
at the end.
There might be something we can do about specifically non-integer roll results, but I don't know if it's within our power at that moment since I believe that roll is generated by Foundry and posted to the chat log directly by Foundry, not by Beyond 20. We just tell it the formula to roll.