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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Str2num does'nt get the decimals

(0) ShareShare
ReportReport
Posted on by 275

Hi

I have a problem with my str conversion.

Str string = 149,2;

Str2num(string) = 149

How can i convert it correctly

*This post is locked for comments

I have the same question (0)
  • Ashein Profile Picture
    275 on at
    RE: Str2num does'nt get the decimals

    Sadly no

  • Verified answer
    Guruprasanna Profile Picture
    1,078 on at
    RE: Str2num does'nt get the decimals

    Hi Ashein,

    you can assign to real variable please find the below piece of code it will give your 149.20

    Str string = "149.2";
    real num;
    num = Str2num(string);
    info(strFmt("%1",num));

    Guru

  • Ashein Profile Picture
    275 on at
    RE: Str2num does'nt get the decimals

    Crispin it was almost correct but when a str uses any2real it does'nt get the decimals.

    And Guruprasanna, thanks it worked.

    Thanks for both quick and good answers.

  • Ashein Profile Picture
    275 on at
    RE: Str2num does'nt get the decimals

    My fault, it did'nt work, but i think it is because of the string uses , instead of . ?

  • Ashein Profile Picture
    275 on at
    RE: Str2num does'nt get the decimals

    It does'nt work when there are a , instead of a .

    I did a quick replace and not it works with str2num

    community.dynamics.com/.../find-a-char-in-string-and-replace-new-char-using-x-in-ax2012

  • Vilmos Kintera Profile Picture
    46,149 on at
    RE: Str2num does'nt get the decimals

    AX respests your Windows Regional and Location settings when it comes to string to decimal value conversion, thus it makes a difference for decimal separator, which is different between the US and majority of the EU contries (dot versus comma). When you provide the value directly as a constant in X++, it uses the comma as the separator as fixed text. When it is a string-based conversion, your locale matters.

  • metin emre Profile Picture
    502 on at
    RE: Str2num does'nt get the decimals

    It's an old thread but maybe this's be useful for someone:

    Try to use Str2Num_RU() . It simple just put "." instead of ",".

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#3
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans