Re: Power arithmetic function to C#



Maarten,

Thank you for your comments! Of course I should have used Floor and
extra parentheses, you're absolutely right.

Truncate is a member in the static Math class, but it is new in the
..net Framework 2.0.
Maybe you are using the 2003 studio?

From MSDN
Math.Truncate Method (Double)
Calculates the integral part of a specified double-precision
floating-point number.

Parameters
d A number to truncate.

Return Value
The integral part of d; that is, the number that remains after any
fractional digits have been discarded.


Check the new "delphi to .net convert" feature in Math.Round, now with
MidPointRounding to be able to specify how mathematical rounding
methods should process a number that is midway between two numbers.
Really nice, new in Framework 2.0 as well

Enum "values":
AwayFromZero
- When a number is halfway between two others, it is rounded toward the
nearest number that is away from zero.
ToEven
- When a number is halfway between two others, it is rounded toward the
nearest even number.



Regards,
Magnus

.



Relevant Pages

  • Re: Floating Point Rounding Mode
    ... > Does anyone know which floating point processor rounding mode various ... > versions of VB use (nearest, up, down, truncate) when dealing with single ...
    (microsoft.public.vb.general.discussion)
  • Floating Point Rounding Mode
    ... versions of VB use (nearest, up, down, truncate) when dealing with single ... and double data types? ...
    (microsoft.public.vb.general.discussion)
  • Easiest way to do this?
    ... I need to be able to take any dollar amount, such as 25103.34, and ... Then I need to take the result and truncate ... nearest cent (ceiling function), so if I have 0.14057, then the result ...
    (comp.lang.perl.misc)