Friday, 17 August 2007

Bug: Diet calculator energy balance fields with decimal fraction

The diet calculator update code failed to round decimal values specified in the Daily balance field to integral values of calories or kilojoules, and also did not accept comma as the decimal character---fixed.

Although daily energy balance figures in the diet calculator are intended to be integral values of calories or kilojoules, we do, in fact, allow the user to specify decimal values, which are rounded to integers when displayed. The JavaScript live update code accepted decimal values in this field but did not accept entries with a comma as the decimal character, parsing them as a NaN and wrecking all of the derived values. I added code to accept energy balance values with comma as the decimal character.

No comments: