fast floor float value - CSharp System

CSharp examples for System:Math Number

Description

fast floor float value

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from ww w  .  j  ava  2s  .c om*/

public class Main{
        // This method is a *lot* faster than using (int)Math.floor(x)
        private static int fastfloor(float x)
        {
            int xi = (int)x;
            return x < xi ? xi - 1 : xi;
        }
}

Related Tutorials