Regex is returning inaccurate/weird numbers.
Numbered Steps to Reproduce Problem:
code below
Code Snippet (if applicable) to Reproduce Problem:
var/regex/comma_expression = new("(\\d)(?=(\\d{3})+$)","g")
#define commafy(x) comma_expression.Replace(num2text(x,12),"$&,")
(code by Nadrew)
Expected Results:
commafy(99999999) should return 99,999,999
commafy(999999951) should return 999,999,951
commafy(999999926) should return 999,999,926
commafy(99999918) should return 99,999,918
Actual Results:
commafy(99999999) returns 100,000,000
commafy(999999951) returns 999,999,936
commafy(999999926) returns 999,999,936
commafy(99999918) returns 99,999,920
Does the problem occur:
Every time? Or how often?
only on numbers with more than 7 sigfigs
In other games?
all my projects
In other user accounts?
On other computers?
When does the problem NOT occur?
when using numbers with 7 or less sigfigs
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Workarounds:
it's an issue with number precision & num2text. the DM VM only is accurate up to 2^24 (which is 16777216).
this will output 16777216. anything higher will output a number *around* that number