Last active
July 3, 2018 09:18
-
-
Save todorok1/d3368c22df93b4d53d1aebd26d84f7ff to your computer and use it in GitHub Desktop.
MathfのRoundを使った時の動作
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void RoundTest(){ | |
float value = 3.15f; | |
Debug.Log("value : " + value + " / Round : " + Mathf.Round(value)); | |
Debug.Log("value : " + value + " / RoundToInt : " + Mathf.RoundToInt(value)); | |
value = -9.61f; | |
Debug.Log("value : " + value + " / Round : " + Mathf.Round(value)); | |
Debug.Log("value : " + value + " / RoundToInt : " + Mathf.RoundToInt(value)); | |
value = 2.51f; | |
Debug.Log("value : " + value + " / Round : " + Mathf.Round(value)); | |
value = 3.5f; | |
Debug.Log("value : " + value + " / Round : " + Mathf.Round(value)); | |
value = 4.5f; | |
Debug.Log("value : " + value + " / Round : " + Mathf.Round(value)); | |
value = 5.5f; | |
Debug.Log("value : " + value + " / Round : " + Mathf.Round(value)); | |
float roundedValue = Mathf.Round(value); | |
// 明示的にキャストが必要 | |
int roundedIntValue = (int) Mathf.Round(value); | |
float roundedToIntValueToFloat = Mathf.RoundToInt(value); | |
int roundedToIntValueToInt = Mathf.RoundToInt(value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment