6,366
editsreply
mNo edit summary |
(reply) |
||
Line 12: | Line 12: | ||
::The formula is correct now, but there's a rounding error. Using the numbers from the test case above, the widget gives 53 and 16 instead of 54 and 17. The in-game sell price of 17 is a rounding of 16.666... but the widget uses a "floor" command. The buy price discrepancy puzzles me. 54 is the exact value (30*1.8). You'd think the calculations must have some intermediary steps where rounding takes place, but I don't see it in the code. A similar error happens with persuasion 12, where it gives a buy price of 38 instead of 39. Even more weirdly, using a persuasion value of 11.99999 gives 39, as one would expect, but entering 12 makes it drop to 38. {{unsigned2| 22:28, 22 November 2023|81.82.46.46}} | ::The formula is correct now, but there's a rounding error. Using the numbers from the test case above, the widget gives 53 and 16 instead of 54 and 17. The in-game sell price of 17 is a rounding of 16.666... but the widget uses a "floor" command. The buy price discrepancy puzzles me. 54 is the exact value (30*1.8). You'd think the calculations must have some intermediary steps where rounding takes place, but I don't see it in the code. A similar error happens with persuasion 12, where it gives a buy price of 38 instead of 39. Even more weirdly, using a persuasion value of 11.99999 gives 39, as one would expect, but entering 12 makes it drop to 38. {{unsigned2| 22:28, 22 November 2023|81.82.46.46}} | ||
::: Ah... one of the great problems of programming. I swapped math.floor with math.round which seems to provide exact values now with the given test case. -[[User:Sky|Sky]] ([[User talk:Sky|talk]]) 22:37, 22 November 2023 (CET) |