[Bug 396278] Re: lcd weather station display issue for temperatures over 99F
Andy St.Martin
andystmartin at cox.net
Wed Sep 2 17:15:20 UTC 2009
There is an operator precedence snafu in WeatherStation::fitValue in
weatherstation.cpp.
The line checking that the number of digits of the temperature is less than the total digits allowed looks like this:
if (mainDigits < 3 && mainDigits + (v < 0)?1:0 + 1 < digits) {
The "?:" is supposed to add 1 ito the mainDigits if the temp is less than 0. However, '+" and '<' have higher precedence than "?:". This yields an expected value. When parentheses are properly inserted, the correct value is evaluated. Such as:
if (mainDigits < 3 && (mainDigits + ((v < 0)?1:0) + 1) < digits) {
Finally, the last "<" should probably be a "<=". If 3 digits are allowed and allowing for a tenth of a degree is 3 or less, then display the tenth. I think the final, correct expression should look something like this:
if (mainDigits < 3 && (mainDigits + ((v < 0)?1:0) + 1) <= digits) {
--
lcd weather station display issue for temperatures over 99F
https://bugs.launchpad.net/bugs/396278
You received this bug notification because you are a member of Kubuntu
Bugs, which is subscribed to kdeplasma-addons in ubuntu.
More information about the kubuntu-bugs
mailing list