Zu viele Nachkommastellen / Danke ist wieder erledigt mit der neuen Pi-hole Version 5.9 und Web Interface v5.11

Hallo,

warum wird in der aktuellen Version der Wert:

ads_percentage_today mit so vielen Nachkommastellen ausgegeben 3.047895 ?

Kann man das nicht wieder auf ein normales Maß reduzieren?

Danke

Are you referring to this output?

echo ">stats >quit" | nc localhost 4711

domains_being_blocked 490932
dns_queries_today 7742
ads_blocked_today 1397
ads_percentage_today 18.044434
unique_domains 1092
queries_forwarded 4846
queries_cached 1487
clients_ever_seen 7
unique_clients 6
dns_queries_all_types 7669
reply_NODATA 257
reply_NXDOMAIN 46
reply_CNAME 482
reply_IP 261
privacy_level 0
status enabled

Correct

A value in percent with 6 decimal places makes no sense.

It is the result of 1397/7742. As this is a real number, there is no simple way to limit the amount of decimals, it's the same number an arbitrary calculator outputs, too. We used to have an ugly workaround of converting it to a string with only two decimal places and then reconvert it into a number but this often caused a number like 6.54 to get 6.540000001 or 6.539999999 because floating point math isn't perfect and cannot all numbers with arbitrary precision. I wouldn't worry too much about it. It's an API output, it shouldn't be shown to human beings without further processing which can (and should) involve conversion to one or at most two decimal places.

1 Like

It just doesn't look nice in iobroker. The data is read directly from the adapter.

Bildschirmfoto 2022-01-18 um 22.09.50

Then iobroker needs to be adjusted to the changed output.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.