fix crash when displaying numbers between [0.1, 1)

This commit is contained in:
Jeff Wang
2019-04-05 00:52:56 -04:00
parent 66c611795e
commit ef298cddd0
2 changed files with 4 additions and 3 deletions

View File

@ -806,7 +806,9 @@ int8_t decn_to_str(char* buf, const dec80* x){
buf[i] = '0';
i++;
INSERT_DOT();
for (j = exponent + 1; j < 0; j++){
//pad zeros right of decimal point
// for (j = exponent + 1; j < 0; j++){ <--- results in undefined behavior (signed overflow), and causes crash
for (j = -exponent -1; j > 0; --j){
buf[i] = '0';
i++;
}