Closed vivekd95 closed 3 months ago
The code intentionally floors (i.e., rounds towards zero), so in your example 0.346999 will display as 0.346.
What you're seeing is the effect of different floating point rounding implementations, when converting a floating point number to a string. Peaks.js does it one way, the browser console does it differently. The underlying value is still the same, though, and there's no loss of precision.
So, the value that I am getting should be the same? If yes, I tried several more things and discovered these screenshot values.
Screenshot of Chrome's console
Screenshot of zoomview
Screenshot of the event triggered
So, is the console showing 2 at the end from the browser's side? The main issue that I am facing is getting the difference of 0.001 when I create in my example.
So, the value that I am getting should be the same?
No, I wouldn't expect the values to be the same, because the Peaks.js library uses a different algorithm to convert the number to a string than the browser console.
The formatPlayheadTime
option allows you to format the value differently, if you want to.
I'll close this, but please re-open if you think more discussion or changes are needed.
Hi @chrisn
When working with zoomview, a new issue is found (checked in the latest release). The current time is getting rounded off (to the ceiling value) when the value after 3 decimals starts with 9 like 0.346999. This value will get rounded off to 0.347 when we use
player.getCurrentTime()
while on zoomview it will show the value before rounding off. Please take a look at the screenshots I've attached below.Screenshot of Chrome's console
Screenshot of the zoomview