c - Correct Hystersis -
i have temperature reading fluctuates. logic chain below right prevent boundary switching on , off?
if (temp > 50) { ac = 100% } else if (temp > 40 && temp < 50) { null; // alter nil } else if (temp > 30 && temp < 40) { ac = 50% } else if (temp > 20 && temp < 30) { null; } else if (temp > 10 && temp < 20) { ac = 25%; } else if (temp < 5) { ac = 0%; }
what null
macro here? leave if
body empty or write ;
(like did).
if you, include such temperatures 40
, 30
, 20
, 10
. isn't clear why omit temperatures 5
, 6
, 7
, 8
, 9
.
with little change, logic must correct:
say, if temp
27, discard <50, <40, <30 , when discards <20, figures out 27 in range [20 .. max]. there's no need in these && temp < 50
- have verified temp
if more 50 , got negative result 27
(in previous if condition), don't heave again.
if (temp >= 50) { ac = 100% } else if (temp >= 40) { ; // alter nil } else if (temp >= 30) { ac = 50% } else if (temp >= 20) { ; } else if (temp >= 10) { ac = 25%; } else { // temp may -1, take consideration. ac = 0%; }
c if-statement
No comments:
Post a Comment