Skip to content

printf format specifier with zero padding behaves incorrectly for negative zero (-0.0) on .NET Core #15558

Closed

Description

@jwosty

printf formatting a value of -0.0 with %010f (or anything which adds some zero padding) incorrectly places the - symbol.

Expected behavior

.NET Core: sprintf "%010.3f" -0.0 should display -00000.000
.NET Framework: sprintf "%010.3f" -0.0 should display 00000.000

This works correctly for other negative values. For example, sprintf "%010.3f" -0.01 displays -00000.100.

Original text `sprintf "%010.3f" -0.0` should display `-00000.000` `sprintf "%010.3f" -0.0` should display `00000.000` (to match .NET Framework).

Actual behavior

Displays 0000-0.000

Known workarounds

None known.

Related information

Potentially related to: #15557

  • macOS 12.6
  • .NET 6.0.15

Activity

  1. added this to the Backlog milestone on Jul 5, 2023
  2. added
    Impact-Low
    Area-Library
    and removed on Jul 10, 2023
  3. jwosty commented on Dec 16, 2024

    @jwosty
    ContributorAuthor

    Noting here that this bug only affects FSharp.Core under .NET Core. See: #18147 (comment)

  4. changed the title [-]printf format specifier with zero padding behaves incorrectly for negative zero (`-0.0`)[/-] [+]printf format specifier with zero padding behaves incorrectly for negative zero (`-0.0`) on .NET Core[/+] on Dec 16, 2024
  5. jwosty commented on Aug 25, 2026

    @jwosty
    ContributorAuthor

    Fixed in #18147

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-LibraryBugImpact-Low

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions