Same said:
I am trying to convert a VB6 app into C# and I cannot find an equivalent to
VB6's Fix Function. Does anyone know if there is one or how to get around
it?
Thanks
Posted in haste...
Actually the MSDN defines Fix(number) = Sign(number) * Int(Abs(number))
I think the following is equivalent
(x >= 0 ? Math.Floor(x) : Math.Ceiling(x))
there may be a better way to replace it though.
Watch out for "rounding" errors.
The MSDN Math.Floor sample shows:
Floor(1.00) = 0
because after 11 subtractions of 0.1 from 2.1 "value" ends up with a number slightly less than 1.0
If you set "value" to exactly 1.0 you get the following result
Floor(1.00) = 1
Decimal.Trunctate may also be worth a look
Returns the integral digits of the specified Decimal; any fractional digits are discarded.
Return Value: The Decimal result of d rounded toward zero, to the nearest whole number.