gcode_parse.c: Limit the digits right of the decimal.
Previously, variables in decfloat_to_int() could overflow due to excess precision, like Z2.0000000.
This commit is contained in:
parent
e44954b333
commit
719a9d32b5
|
|
@ -292,8 +292,10 @@ void gcode_parse_char(uint8_t c) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// can't do ranges in switch..case, so process actual digits here
|
// can't do ranges in switch..case, so process actual digits here. Limit the digits right of the decimal to avoid variable overflow in decfloat_to_int() due to excess precision
|
||||||
if (c >= '0' && c <= '9') {
|
if (c >= '0' && c <= '9' &&
|
||||||
|
((next_target.option_inches == 0 && read_digit.exponent < 4) ||
|
||||||
|
(next_target.option_inches && read_digit.exponent < 5))) {
|
||||||
// this is simply mantissa = (mantissa * 10) + atoi(c) in different clothes
|
// this is simply mantissa = (mantissa * 10) + atoi(c) in different clothes
|
||||||
read_digit.mantissa = (read_digit.mantissa << 3) + (read_digit.mantissa << 1) + (c - '0');
|
read_digit.mantissa = (read_digit.mantissa << 3) + (read_digit.mantissa << 1) + (c - '0');
|
||||||
if (read_digit.exponent)
|
if (read_digit.exponent)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue