コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【C#】float 型がほぼ整数なら true を返す拡張メソッド

ソースコード

public static bool IsApproximatelyInteger( this float value, float tolerance )
{
    return Mathf.Abs( Mathf.Round( value ) - value ) <= tolerance;
}