Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Unanswered

DecRound not working as expected sometimes

Posted on by 5

I have to round some field data with 2 decimal positions, when i run it in a job (client side), it just works as expected:

Screenshot_5F00_20190416_5F00_102510.png

it works because, in this case, i want to get 110.03, that is the right number rounded.

But, when i try to use this one in a web service (server side), it just does not get rounded, i just get 110.02, instead of 110.03 (the right value). See the image:

Screenshot_5F00_20190416_5F00_102211.png

See decRounded, the value is 110.025, and this rounded should be 110.03 instead of 110.02,

Is there a reason for this behavior?

  • mpinto198 Profile Picture
    mpinto198 5 on at
    RE: DecRound not working as expected sometimes

    docs.microsoft.com/.../system.math.round;view=netframework-4.7.2#System_Math_Round_System_Double_System_Int32_System_MidpointRounding_

    I have to use System.Math.Round, to fix this behavior.

    System.Math::Round(value,decimals,System.MidpointRounding::AwayFromZero)

    The MidpointRounding::AwayFromZero was the trick.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,773 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,513 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans