切记:
float test;
进行除法运算的时候要注意:
test = 8 / 10;
Debug.log(" test is ---> "+ test); =====> test is 0;
改:
test = 8 .0f / 10.0f;
Debug.log(" test is ---> "+ test); =====> test is 0.8;
本文揭示了在使用整数进行除法运算时,如果不转换为浮点数会导致结果被截断为0的问题。通过具体示例展示了如何正确地进行浮点数除法运算,避免结果失真。
切记:
float test;
进行除法运算的时候要注意:
test = 8 / 10;
Debug.log(" test is ---> "+ test); =====> test is 0;
改:
test = 8 .0f / 10.0f;
Debug.log(" test is ---> "+ test); =====> test is 0.8;
您可能感兴趣的与本文相关的镜像
TensorFlow-v2.9
TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型
2216

被折叠的 条评论
为什么被折叠?