lcd weather station display issue for temperatures over 99F
Bug #396278 reported by
Andy St.Martin
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
kdeplasma-addons (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: plasma-
The LCD Weather Station plasma widget does not correctly display temperatures over 99.9 F. This occurs when in the "small" format in the "panel". Only 3 digits are displayed. Instead of displaying "105.0"; "05.0" is displayed.
It would be fine if the tenths of degrees were dropped and "105" was displayed. (After 101F, tenths of degrees are not significant :-) )
This was found in the KDE 4.3 RC1 backport to Jaunty: 4:4.2.95-
To post a comment you must log in.
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) {