Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

Subtraction of Real numbers-Negative value

Posted on by 487

Hi,

I have a job

static void Job297(Args _args)
{
 RealBase t1,t2,t3;
    
    t1=0.0833;
    t2=1/12;
    t3=t1-t2;
    info(strFmt("%1",t3));
}

the answer is -0.0

Why-may i know why it shows negative value

How to get rid of neagtive value

I tried with

t1-rounddDecup(t1,3) -even though the value is 0.00 in info log , in table it gets saved as -0.0

From where do AX takes the negative sign

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Subtraction of Real numbers-Negative value

    Hello NDingankar22,

    That is not AX fault!

    t2=1/12 is actually 0.0833333333333333.

    You are trying to subtract 0.0833 with a higher number, which is why the negative sign appears.

    You are working with real numbers, if you want to get the result 0.000 try to hardcode your variables to 4 decimal points.

    All the best!

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans