I'm looking for an implementation of floor(x) in C# so that it would match the C++ version.
floor of 2.3 is 2.0
floor of 3.8 is 3.0
floor of -2.3 is -3.0
floor of -3.8 is -4.0
Since a C++ reviewer will be checking my code, what implementation of floor
is reasonable in C# so that he doesn't pull out his (last remaining) hairs?
You can use the Math class. There are many overloaded form of Math.Floor
Simple Usage :
Math.Floor(2.3) // == 2.0
Math.Floor(3.8) // == 3.0
Math.Floor(-2.3) // == -3.0
Math.Floor(-3.8) // == -4.0