鸟语天空
Mathf.Approximately()
post by:追风剑情 2017-6-9 18:45

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

评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容