Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • mata strtoreal() in Stata 19

    Hi,

    Stata 18:

    Code:
    . mata
    ------------------------------------------------- mata (type end to exit) -------------------------------------------
    : strtoreal("0.01")
      .01
    Stata 19:

    Code:
    . mata
    ------------------------------------------------- mata (type end to exit) -------------------------------------------
     : strtoreal("0.01")
      0
    Why was this changed, and, more importantly, how do I get the version 18 result back in (which seems to be more correct in many applicaitons).

    Uli

  • #2
    We tested on Windows, Linux, and 3 different Mac and were not able to reproduce the behavior. The following is what I got running xmp on Linux:

    Code:
    . about
    
    StataNow/MP 19.5 for Unix (Linux 64-bit x86-64)
    Revision 08 Apr 2025
    Copyright 1985-2025 StataCorp LLC
    
    Total usable memory: 251.82 GB
    
    . mata:
    ------------------------------------------------- mata (type end to exit) ------
    : strtoreal("0.01")
      .01
    Would you mind share you platform information? What's the OS, what flavor of Stata?

    Comment


    • #3
      Code:
      . about
      
      StataNow/SE 19.5 for Unix (Linux 64-bit x86-64)
      Revision 08 Apr 2025
      Copyright 1985-2025 StataCorp LLC
      
      Total usable memory: 15,39 GB
      
      [...]
      . mata
      ------------------------------------------------- mata (type end to exit) -------------------------------------------
      : strtoreal("0.01")
        0

      Linux is:


      Code:
      ~$ lsb_release -a
      No LSB modules are available.
      Distributor ID:    Ubuntu
      Description:    Ubuntu 22.04.5 LTS
      Release:    22.04
      Codename:    jammy
      ~$ uname -r
      5.15.0-136-generic

      Comment


      • #4
        Would you try the following?

        Code:
        mata:
        _strtoreal("0.01", a=.)
        a
        On my Linux machine running Stata, it displays:

        Code:
        . mata:
        ------------------------------------------------- mata (type end to exit) ------
        : _strtoreal("0.01", a=.)
          0
        
        : a
          .01

        Comment


        • #5
          Code:
          . mata:
          ------------------------------------------------- mata (type end to exit) -------------------------------------------
          : 
          : _strtoreal("0.01", a=.)
            0
          
          : 
          : a
            0

          Comment


          • #6
            Thanks, we are able to reproduce it. When the OS locale is set to de_DE.UTF-8, the function returned 0 instead of 0.01. We will report back when we have a solution.

            Comment


            • #7
              We had removed some locale code that was being deprecated by the GUI toolkit we use which is the source of the issue. This only affected the GUI version of Stata on Linux when the language is set to a language that uses a comma as a decimal separator. We will fix this in an update. For now, prefix your command that launches Stata with LANG="C". For example, LANG="C" /usr/local/statanow19/xstata-se.
              Last edited by Chinh Nguyen (StataCorp); 10 Apr 2025, 08:50.
              -Chinh Nguyen

              Comment


              • #8
                I confirm that Chinh's workaround works here as well. If I understand correctly, any German Stata User using Linux who likes to use my recently published unitchg package should prefix the command to start Stata with LANG="C". Thank you, Hua and Chinh, for reacting so quickly to this admittedly minor problem. Looking forward to the update.

                Uli

                Comment

                Working...
                X