Skip to content

printf sometimes doesn't round numbers to even #6405

Description

@dustwanderer

Description / Steps to reproduce the issue

1- printf "%.1f %.1f" 76.75 76.85 = 76.8 76.8 # Round to nearest and ties to even.
2- printf "%.0f %.0f" 24.5 25.5 = 24 26 # Round to nearest and ties to even.
3- printf "%.1f %.1f" 2.45 2.55 = 2.5 2.5 # Whatever happened to ties to even?

Expected behavior

printf "%.1f %.1f" 2.45 2.55 should output "2.4 2.6". That would follow standard conventions and will be coherent with printf rounding of "24.5 25.5" to "24 26".

Actual behavior

printf "%.1f %.1f" 2.45 2.55 outputs "2.5 2.5".

Verification

Windows Version

MSYS_NT-10.0-26200

Are you willing to submit a PR?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions