Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
無限大について全力で考えてみる
void CompareInfinity(){
// floatのInfinityをキャストするとdoubleではどうなるか
double infFromFloat = float.PositiveInfinity;
Debug.Log("infFromFloat : " + infFromFloat);
// MathfのInfinityをキャストするとdoubleではどうなるか
double infFromMathf = Mathf.Infinity;
Debug.Log("infFromMathf : " + infFromMathf);
// floatでの計算結果が最大値を超える場合はどうなるか
double overMax = float.MaxValue + 1.0e+33f;
Debug.Log("overMax : " + overMax);
// doubleのInfinityをキャストするとfloatではどうなるか
float infFromDouble = (float) double.PositiveInfinity;
Debug.Log("infFromDouble : " + infFromDouble);
// floatの最大値を超えるdoubleの値をキャスト
float overMaxFromDouble = (float) 1.0e+200;
Debug.Log("overMaxFromDouble : " + overMaxFromDouble);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.