~valhalla/lesana#3: 
Decimal fields are shown as string representation of floats

To reproduce:

  • create an entry with a decimal field, enter some value (e.g. 3.17)
  • lesana show

it will show '3.1699999999999999289457264239899814128875732421875' as the value for that field.

(The same thing happens in the lesanaweb templates).

Status
REPORTED
Submitter
~valhalla
Assigned to
Submitted
4 years ago
Updated
3 years ago
Labels
bug

Elena ``of Valhalla'' 4 years ago ยท edit

This is caused by the fact that the value is loaded as a float by the yaml reader, before lesana interacts with it, and thus it is converted to Decimal after it has been represented as a binary floating point.

#The workaround is to store such values as strings with explicit quoting (e.g. cost: '1.99') so that it is correctly converted to Decimal without loss of precision.

Elena ``of Valhalla''

~valhalla 3 years ago

From commit 4023903e there is also a property precision to force rounding all values for a decimal field to a certain number of decimal digits.

Register here or Log in to comment, or comment via email.