Version: 2018.1
public static bool Approximately (float a, float b);

説明

2 つの浮動小数点値を比較し、近似している場合は true を返します。

浮動小数点の不正確さによって、等号演算子を使用した float の比較を不正確にします。 例えば、(1.0 == 10.0 / 10.0) は毎回 true を返すわけではありません。 Approximately() は2つの float を比較し、それらが互いに小さな値 (Epsilon) の範囲内にある場合 true を返します。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Example() { if (Mathf.Approximately(1.0F, 10.0F / 10.0F)) print("The values are approximately the same"); } }