sports-lib
sports-lib copied to clipboard
[Discussion] Should Data values be stored to their precision?
Due to several calculations eg adding up distance the result can have many decimal places
eg
1.2348292993
During the Strava compliance tests eg strava reports distance with 1 decimal
1.2
- Should this rounding be applied on the consumer (App using this lib)?
- Should this rounding be defined at least in this library eg
getValue(precise)
? - Should it all fall to the side of the consumer (App using this lib)
As a user of the lib. I would prefer to receive the full value (no rounding). So that I can round the results on my end.
However, it would be nice to have a helper function that would allow me to specify the precision. PS: great project, thanks for making it public, and publishing to npmjs cheers!
@guikeller Agreed. I ll look into this. Currently you can:
distance = new DataDistance(1.222222222)
distance.getValue() // Gives back the full precision
distance.getDisplayValue() // Gives back a predifined precision
One could for now at least do something like distance.getValue().toFixed(2)
for example
(The above applies to all data)
I ll take a look how this can become more robust