Avoid (double) divide-by-zero.
On startup, maxValue may be 0 (e.g. for auto-adjusting sensors) and then we get a divide-by-zero. In practice this hammers the resulting integer to negative-biggity, but it's still undefined behavior. Just use 0 instead. While here, massage the C-style cast as well. Make the whole ternary expression a double, then cast.
parent
14a7a4bc
Please register or sign in to comment