Tuesday, August 12, 2008

Rounding in AX (real to integer)

How to perform a successful round in AX from real to integer?...
Well, the answer is: use the function decround.

static void Job1(Args _args)
{
    int i, ii;
    real r = 334.55, r2 = 334.14;
    ;

    i = decround(r, 0);
    ii = decround(r2, 0);

    // It shows 335, 334
    info(strfmt("%1, %2", i, ii));
}


1 comments:

Anonymous said...

Well I guess the result would actually be something like this:
335.00 and 334.00 - could be relevant that it still outputs the decimals when using in regard to exports for external systems. As far as I can tell - you need to go through real2int as well


View My Stats