Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Math.Ceil Function equivalent

Posted on by Microsoft Employee

Hi all,

 

I am after an equivalent Math.ceiling function for Decimal/Double/Real numbers in AX 2012 X++ programming. I would like to round up to the the next whole Decimal but can't seem to get the desired outcome using decRound(Number, 0) or  round(Number, 1).

For example if Number is 1.10 I want the output to be 2

Please help! Thanks.

*This post is locked for comments

  • MukeshHirwani Profile Picture
    MukeshHirwani 1,180 on at
    RE: Math.Ceil Function equivalent

    static void Job1(Args _args)

    {

       real i = 1.10;

       print round(i,2);

       pause;

    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Math.Ceil Function equivalent

    Many thanks Kyle and Martin. The roundUp() function worked for me but not the System.Math::Ceiling()

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,149 Most Valuable Professional on at
    RE: Math.Ceil Function equivalent

    Using .NET Interop from X++ works, but it's slow, may require Interop permission and so on.

    You can do the same in X++ by roundUp(number, 1) or roundUpDec(number, 0).

  • Suggested answer
    Kyle Wascher Profile Picture
    Kyle Wascher 185 on at
    RE: Math.Ceil Function equivalent

    You can use .NET inside x++.

    static void Job1(Args _args)

    {

       real testNum = 1.10;

       real result;

       result = System.Math::Ceiling(testNum);

       info(strFmt("%1", result));

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans