pulse counter values rounding error?


I've been using emoncms since last September and have built up quite a number of inputs now (about 100, with about 350 feeds).

All in all it's been great so far, but I've just added some pulse counter inputs and have some sort of rounding error.

I'm using an older version of emoncms as at the moment I don't want to upgrade and disturb what is essentially a well working setup:

 git log
commit 2560da7b9fc964a56c975a63364c1b6e0f69e038
Author: Trystan Lea <trystan.lea@googlemail.com>
Date:   Wed Sep 25 14:23:42 2013 +0100


The error that I'm seeing is that an input post like:


(so the value is 311957792)

is becoming rounded somehow in the feed db:

mysql> select * from feed_44 limit 1;

| time       | data      |
| 1380491737 | 311957000 |

So this means that any input processing I attempt, for example pulse difference, is then out of whack. 

Is this a bug?  Have I hit some limit somewhere due to the pulse counter value being quite high - they have been running for many years :-)

Any ideas where I can look to attempt to fix the problem?

Thanks for any help!


Edit - added formatting to MySQL table

martynwendon's picture

Re: pulse counter values rounding error?

Seems this is a problem with Float precision with large values.

I took a scout through the code but it seems it would take a fair chunk of work to sort out - either a lot of casting backwards and forwards to get the precise values or maybe an underlying change of field type in the db (store everything as a string maybe?)

For the time being I worked around it by resetting the counters in my pulse meters, so they're starting from zero.





Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.