flowerinsnow-lights-opensource / GreatScrollableTooltips

Minecraft Mod/Allow scrolling of item tooltips in the inventory.
https://modrinth.com/project/great-scrollable-tooltips
Mozilla Public License 2.0
2 stars 0 forks source link

算法错误导致在配置界面中每次保存都会使灵敏度异常波动 / An algorithm error causes the sensitivity to fluctuate abnormally every time it is saved in the configuration interface. #26

Closed flowerinsnowdh closed 6 months ago

flowerinsnowdh commented 6 months ago

由于滑块进度和灵敏度值的算法是

灵敏度 = [(int) (滑块进度 * 99.0)] + 1

滑块进度 = [(decimal) (灵敏度 - 1]) / 99.0 (保留2位小数)

两者都是向下取整,取整时会丢失精确的数值,导致保存再加载会导致灵敏度向下波动


Since the algorithm for slider progress and sensitivity values is

Sensitivity = [(int) (Slider Progress 99.0) + 1]*

Slider Progress = [(decimal) (Sensitivity - 1)] / 99.0 (Keep 2 decimal places)

Both are rounded down. The precise value will be lost during rounding, causing the sensitivity to fluctuate downward when saving and reloading.