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)

X++ : How to get the fraction numbers without the point?

(0) ShareShare
ReportReport
Posted on by 1,036

Hello awesome community! I'm new to ax and report development and I seek your help if you please :)

If there is a real number for example: 1234.56.

How can I get "56" the fraction part without the point?

I know about the built-in function "frac()" but it returns it with the point "0.56".

I thought of multiplying the result of frac() with 100, but it won't be correct if the fraction part has more than 2 digits.

is there a method or a way that can get the fraction part without the decimal point?

Thanks in advance!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mea_ Profile Picture
    60,284 on at

    Hi Momochi,

    There is no magic function to convert 0.1412548 to 1412548, the easiest way would be to convert it to the string, remove 0. and convert it to int.

  • Verified answer
    Mohammed Khatib Profile Picture
    430 on at

    Try the following piece of code, however I believe it might affect the performance:

       real    number = 123456789.987654321;

       str     value = num2str(number,0,7,0,0);

       str     fraction;

       int     result;

       List segments = new List(Types::String);

       ListEnumerator enumerator;

       segments = strSplit(value, ".");

       enumerator = segments.getEnumerator();

       while(enumerator.moveNext())

       {

           fraction = enumerator.current();

       }

       result = str2int(fraction);

       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

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