关于godot游戏引擎中常见的小数除以大数结果为0的问题

这种问题常见于求百分比的需求。

如:5/100 , 6/120 ,前面的数小,后面的数字大

这种情况下,可以使用5.0/100 来进行解决,或者 5.0/100.0

或者6.0 / 120 或者 6.0/120.0

关于这个细节,余数为0,是由于C++的触发截断问题,详情见godot文档。

about division truncation in godot (math problem) · godotengine/godot-proposals · Discussion #7284 (github.com)

以上是我在github提出的问题,仅供参考

猜你喜欢

转载自blog.csdn.net/weixin_43539313/article/details/131734400