Closed dracarys18 closed 6 months ago
Odd. I've confirmed that the code as-is does what you say, so I'll definitely look into this more.
It looks like it's rounding off the time to 60 seconds and it's happening every minute.
Confirmed. This appears to be the behavior of Display
for floats, and to be fair it is what 99.9% of people would expect (as it's the closest to the true value). I naïvely assumed that it would truncate, and a quick search just now reveals that the behavior isn't actually documented.
Given that I can't rely on the standard library's implementations here, I'm going to have to manually format floats. It's doable and I'll probably get to it this weekend.
It looks like it's rounding off the time to 60 seconds and it's happening every minute.
Confirmed. This appears to be the behavior of
Display
for floats, and to be fair it is what 99.9% of people would expect (as it's the closest to the true value). I naïvely assumed that it would truncate, and a quick search just now reveals that the behavior isn't actually documented.Given that I can't rely on the standard library's implementations here, I'm going to have to manually format floats. It's doable and I'll probably get to it this weekend.
Sure @jhpratt, I can take this up if you just give me a place where I should start looking at.
The specific function is format_float
in src/formatting/mod.rs
. The Some
arm is what is relevant.
The specific function is
format_float
insrc/formatting/mod.rs
. TheSome
arm is what is relevant.
Sure I will take a look and create a PR for this. Thanks!
Hey @jhpratt, So this can be fixed by just truncating the float number to the precision point before we pass it to formatter. Playground link for it. This would require just a one line change in format_float
function where we would just truncate value
before it we pass it in write!
. Let me know if you have better suggestions, Otherwise I will create a PR for this.
Hi @jhpratt continuing our discussion from #674. I have created a repo to reproduce this bug here. You can try to run it and check it yourself.
This looks like this happens only when the TimePrecision is 3 here.
It looks like it's rounding off the time to 60 seconds and it's happening every minute. If I change the precision to 6 I can see it's adjusting to nano second