Announcement

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

  • Bug: numbers converted to string get the letter "g" added to the end if about 10^19 in general format with over 20 decimal places

    I'm using Stata MP 19.5 for Mac. When I run:

    Code:
    clear all
    set obs 1
    gen double glitched_tostring = 10^19
    tostring glitched_tostring, format("%50.21g") replace force
    di glitched_tostring[1]
    The output is:

    Code:
    1000000000000000000.g
    Which seems to have a random letter g added to the end. This seems to only happen when:

    *The number is at least 10^19, and smaller than 10^20
    *The format specifies more than 20 decimals
    *The format type ends in g or gc

  • #2
    Huh, I just noticed that the actual output minus the ".g" is no longer on the order of 10^19, and is now 10^18.

    So it's not that ".g" gets appended onto the end, but it actually replaces the last digit.

    Comment


    • #3
      We are able to reproduce it and am looking into the issue.

      Comment

      Working...
      X