Skip to content

Instantly share code, notes, and snippets.

@todorok1
Created June 15, 2018 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todorok1/bb929ecf2ae2b1b598fb0c051f8e632b to your computer and use it in GitHub Desktop.
Save todorok1/bb929ecf2ae2b1b598fb0c051f8e632b to your computer and use it in GitHub Desktop.
無限大について全力で考えてみる
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