Mathf.Round

Deklarasyon

public static float Round(float f);


Açıklama

f'yi en yakın tam sayıya yuvarlar.

Eğer sayı .5 ile bitiyorsa ve iki tam sayı arasında kalıyorsa, biri çift diğeri tek ise, çift olan sayı döndürülür.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    // Başlatma için kullanılır
    void Start()
    {
        // 10 yazdırır
        Debug.Log(Mathf.Round(10.0f));

        // 10 yazdırır
        Debug.Log(Mathf.Round(10.2f));

        // 11 yazdırır
        Debug.Log(Mathf.Round(10.7f));

        // 10 yazdırır
        Debug.Log(Mathf.Round(10.5f));

        // 12 yazdırır
        Debug.Log(Mathf.Round(11.5f));

        // -10 yazdırır
        Debug.Log(Mathf.Round(-10.0f));

        // -10 yazdırır
        Debug.Log(Mathf.Round(-10.2f));

        // -11 yazdırır
        Debug.Log(Mathf.Round(-10.7f));

        // -10 yazdırır
        Debug.Log(Mathf.Round(-10.5f));

        // -12 yazdırır
        Debug.Log(Mathf.Round(-11.5f));
    }
}


Bu blog Unity Docs'un Türkçeye çevrilmiş halidir.

Yorumlar

Bu blogdaki popüler yayınlar

Important Classes - Vectors

RequireComponent

Important Classes - GameObject