您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
33 行
742 B
33 行
742 B
/*
|
|
Script Source: https://coffeebraingames.wordpress.com/2013/12/18/a-generic-floating-point-comparison-class/
|
|
*/
|
|
|
|
using UnityEngine;
|
|
|
|
/**
|
|
* Class for comparing floating point values
|
|
*/
|
|
public static class Comparison {
|
|
|
|
/**
|
|
* Returns whether or not a == b
|
|
*/
|
|
public static bool TolerantEquals(float a, float b) {
|
|
return Mathf.Approximately(a, b);
|
|
}
|
|
|
|
/**
|
|
* Returns whether or not a >= b
|
|
*/
|
|
public static bool TolerantGreaterThanOrEquals(float a, float b) {
|
|
return a > b || TolerantEquals(a, b);
|
|
}
|
|
|
|
/**
|
|
* Returns whether or not a <= b
|
|
*/
|
|
public static bool TolerantLesserThanOrEquals(float a, float b) {
|
|
return a < b || TolerantEquals(a, b);
|
|
}
|
|
|
|
}
|