DKP Values Stored as singles
caspervk opened this issue · 3 comments
If it helps, this is how I fixed it:
Values are stored properly as floats. It's display that is flawed. Could you point me to the points where you know they are displayed improperly?
The problem is that storing the value as a floating point -- 32 bit single-precision floating-point especially -- results in imprecision. The the example above, 11.6
, can never be represented correctly in this format. Fixing the display might make the problem appear to be solved, but it will only mask the issue, and it is likely that the errors will compound. It is for this reason that any currency in a computer is either stored using fixed-point decimals or as integers in its smallest divisible unit; e.g. cents, Bitcoin Satoshi, or in this case, µDKP. The AddOn even allows us to work to four decimal places as a setting, but using the current representation it is unable to distinguish numbers to this precision, e.g. 1000.10
is actually stored and represented as 1000.0999755859375
.