Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tinystdio: Add a fix for rounding in case of 0 decimal places for fmode #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

A-Shehab
Copy link
Collaborator

before this change, in case of rouding to 0 decimal places with fmode for 0 < x < 1
some numbers get printed incorrectly such as 0,45 gets rounded to 1 instead of 0

it's because rounding happens in dtoa_ryu.c d2d function then another rounding
happens in vfprintf function itself, because that cascading rounding results in
incorrect results incase of rounding to 0 decimal places, this change prevents
the extra rounding that happens in dtoa_ryu.c and rely on vfprintf rounding for
this case.

before this change, in case of rouding to 0 decimal places with fmode for 0 < x < 1
some numbers get printed incorrectly such as 0,45 gets rounded to 1 instead of 0

it's because rounding happens in dtoa_ryu.c d2d function then another rounding
happens in vfprintf function itself, because that cascading rounding results in
incorrect results incase of rounding to 0 decimal places, this change prevents
the extra rounding that happens in dtoa_ryu.c and rely on vfprintf rounding for
this case.

Signed-off-by: Ahmed Shehab <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant