fix crash when displaying numbers between [0.1, 1)
This commit is contained in:
parent
66c611795e
commit
ef298cddd0
@ -132,8 +132,7 @@ The keys on the original calculator map as follows:
|
|||||||
Hold `mode` and `0` at the same time to turn off. NOTE: There is no auto power off.
|
Hold `mode` and `0` at the same time to turn off. NOTE: There is no auto power off.
|
||||||
|
|
||||||
# Bugs
|
# Bugs
|
||||||
1. Currently, trying to display numbers between `[0.1, 1)` causes the calculator to crash.
|
1. The calculator does not properly check for overflow.
|
||||||
1. There are other calculations which can randomly cause the calculator to crash.
|
|
||||||
1. There are probably more bugs waiting to be discovered.
|
1. There are probably more bugs waiting to be discovered.
|
||||||
|
|
||||||
# Internals
|
# Internals
|
||||||
|
@ -806,7 +806,9 @@ int8_t decn_to_str(char* buf, const dec80* x){
|
|||||||
buf[i] = '0';
|
buf[i] = '0';
|
||||||
i++;
|
i++;
|
||||||
INSERT_DOT();
|
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';
|
buf[i] = '0';
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user