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

Announcements

No record found.

News and Announcements icon
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,677 Super User 2026 Season 1 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans