Mathf.Approximately()

作者:追风剑情 发布于:2017-6-9 18:45 分类:Unity3d

public static bool Approximately(float a, float b);

判断两个float型是否近似相等。

示例

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class ExampleClass : MonoBehaviour
  5. {
  6. void Start()
  7. {
  8. float a = 1.0f;
  9. float b = 10.00001f / 10.0f;
  10. Debug.Log("a="+a);
  11. Debug.Log("b="+b);
  12.  
  13. Debug.Log(a == b);
  14.  
  15. //判断两个float型是否近似相等
  16. Debug.Log(Mathf.Approximately(a, b));
  17. }
  18. }

输出

11111.jpg

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号