web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to format real

(0) ShareShare
ReportReport
Posted on by 916

Hi ,

I have a real and i want to format it  :

static void Job_Num2Str(Args _args)
{
real realNum = 164740.1294567890123456777;;

info(strFmt("RealToStr %1",Num2Str(realNum,0,17,1,3)));

}

this job show : 

RealToStr  164 740.13

but me i want to get 164 740.12 and keep type of variable because Num2Str convert real to string

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    If you want to show the number in an infolog you have to convert it to string. You can of course keep it as real in your code, but then you can't show it via infolog.

    The function num2str rounds the number to the specified number of decimals where 9 seems to be the max. So 17 does't work. If you want to see .12 then you would have to use different rounding function first where you specify to always round down (.Net offers those), since normal rounding will round .129 to .13 or you truncate the number after two decimals.

  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    You can round it to 0.02

    real realNum = 164740.1294567890123456777;;
        
     realNum = round(realNum,0.02);
       
    info(strFmt("RealToStr %1",Num2Str(realNum,0,17,1,3))); 


  • ALAhmed Profile Picture
    916 on at

    @Sohaib Cheema   Thank you

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans