Thanks for your comment, Petr - yes, you are right, my first attempt can't work when a non-empty field should be updated to an empty one. The new attached patch (
MDL-14788_20080512.patch) works perfectly for me - I tested it under all cases. Your attempt would still display all empty fields as the number 0.
I don't see a need to add an option allowing empty fields - why make things more complicated? Please think how everybody knows a number field to behave in Excel for example - an empty number field will never be implicitly replaced with the number 0 - the way Moodle currently treats the number is simply mathematically wrong. Having a measurement result of 0.002 and having no result at all are completely different cases, however, Moodle would display both values identically, as 0.00 (assuming my patch
MDL-14771 has been applied and you have specified 2 decimals). Thus, I really see this as a bug to be fixed in 1.9.1 and not as a new feature.