Skip to content
  • Adriaan de Groot's avatar
    Avoid (double) divide-by-zero. · b972e777
    Adriaan de Groot authored
    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.
    b972e777