Mathf.Approximately()

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

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

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

示例

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void Start()
    {
        float a = 1.0f;
        float b = 10.00001f / 10.0f;
        Debug.Log("a="+a);
        Debug.Log("b="+b);

        Debug.Log(a == b);

        //判断两个float型是否近似相等
        Debug.Log(Mathf.Approximately(a, b));
    }
}

输出

11111.jpg

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号