goutils icon indicating copy to clipboard operation
goutils copied to clipboard

randNumeric returns values that are interpreted as octal

Open danielhoherd opened this issue 3 years ago • 0 comments

randNumeric returns values that are interpreted as octal. This causes problems when randNumeric returns numbers that are invalid octal numbers, like 08 and 09. Errors related to this happen silently when passed to mul and div, resulting in random numbers that are heavily weighted to 0.

EG: when running 1000 iterations of {{ mul (randNumeric 2) 6 }}, the top 5 chosen numbers and their count were:

number times chosen
30 16
156 17
24 17
468 18
0 36

When attempting things like {{ mul 08 6 }}, {{ div 09 3 }} a parse error arises, but when the octal numbers are generated by randNumeric the octal numbers are accepted and no error is seen.

danielhoherd avatar Oct 20 '20 00:10 danielhoherd