Fix #13611: Zero under decimal is not displayed#13618
Conversation
|
Are you able to write a unit test for this? |
|
yes, but I was trying to figure out where the format for it is specified. I assume I can just add a TEST_F method to the tests/FormattingTests.cpp file? |
| // handle case where value has fewer sig figs than required decimal places | ||
| while (num == 0 && i < TDecimalPlace && i < sizeof(buffer)) | ||
| { | ||
| buffer[i++] = static_cast<char>('0'); |
There was a problem hiding this comment.
Surely the static cast is not required.
There was a problem hiding this comment.
yes certainly not required, just put it there for consistency/readability with the prior line that makes use of '0' char literal as an offset: static_cast<char>('0' + (num % 10)). Removing the static cast probably won't have any effect on code generation, but if you'd prefer it be removed for style I can.
There was a problem hiding this comment.
I agree, just remove it if it isn't required.
There was a problem hiding this comment.
I have removed the explicit cast; I made my commit summary message slightly too long though and got caught by the CI linter; is there anything I need to do about that (e.g. commit --amend) or is it more of a reminder?
There was a problem hiding this comment.
Just amend the commit the Mac os ci has failed as well. Might be unrelated though.
There was a problem hiding this comment.
Mac CI mysteriously had a connection timeout during upload phase from what I could tell, might just be a random glitch with CI
There was a problem hiding this comment.
Yeah Mac CI always seems to have issues.
- already a char literal and assigning to char[] so code is functionally equivalent
c06514a to
f3b21fe
Compare
The existing code does not properly handle the formatting conversion case for fixed point decimal values. If a fixed point integer representation has fewer significant figures than the required fixed point precision, no zeros are placed between the decimal place and the first sig fig. This causes ride intensity, nausea etc. to display incorrectly when very small values, e.g. a nausea value of 0.05 will be displayed as 0.5.