Essential DKP

Essential DKP

6.1k Downloads

DKP Values Stored as singles

caspervk opened this issue · 3 comments

commented

It looks like DKP values are stored as singles in some places:
image
On the other hand, the value is correctly shown in other places:
image
I haven't looked through the code, but as with all currency, maybe the numbers should be stored as integers (in µDKP) or as Decimal?

commented

If it helps, this is how I fixed it:

Vapok#6

commented

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?

commented

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.