Mathf
- Abs
- Acos
- Approximately
- Asin
- Atan2
- Atan
- CeilToInt
- Ceil
- Clamp01
- Clamp
- ClosestPowerOfTwo
- Cos
- Deg2Rad
- DeltaAngle
- Epsilon
- Exp
- FloorToInt
- Floor
- Infinity
- InverseLerp
- IsPowerOfTwo
- LerpAngle
- Lerp
- Log10
- Log
- Max
- Min
- MoveTowardsAngle
- MoveTowards
- NegativeInfinity
- NextPowerOfTwo
- PingPong
- PI
- Pow
- Rad2Deg
- Repeat
- RoundToInt
- Round
- Sign
- Sin
- SmoothDampAngle
- SmoothDamp
- SmoothStep
- Sqrt
- Tan
Mathf.Approximately 近似
static function Approximately (a : float, b : float) : bool
Description描述
Compares two floating point values if they are similar.
比较两个浮点数值,看它们是否非常接近。
Due to floating point imprecision it is not recommended to compare floats using the equal operator. eg. 1.0 == 10.0 / 10.0 might not return true.
由于浮点数值不精确,不建议使用等于来比较它们。例如,1.0==10.0/10.0也许不会返回true。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public void Awake() {
if (Mathf.Approximately(1.0F, 10.0F / 10.0F))
print("same");
}
}
if (Mathf.Approximately(1.0, 10.0/10.0))
print ("same");
最后修改:2011年2月23日 Wednesday 15:39