Skip to content

[Bug]: When using "%0[width]d" to format a negative integer, the minus sign is placed incorrectly #2328

Open
@F1F88

Description

@F1F88

Prerequisites

  • I have checked that my issue doesn't exist yet in the issue tracker

Operating System and Version

Windows 11 24H2

Game / AppID and Version

NMRIH version 1.14.2

SourceMod Version

1.12.0-git7197

Metamod:Source Version

1.12.0-git1219

Version Verification

Updated SourceMod Version

1.13.0-git7241

Updated Metamod:Source Version

2.0.0-1350

Description

When using "%0[width]d" to format a negative integer, the minus sign is formatted before the integer value but after the filler '0'.

Steps to Reproduce

#include <sourcemod>

public void OnPluginStart()
{
    PrintToServer("Int: (%d)", -123);
    PrintToServer("Int: (%7d)", -123);
    PrintToServer("Int: (%07d)", -123);
    PrintToServer("Int: (%-07d)", -123);
}

Relevant Log Output

Expected Output:

Int: (-123)
Int: (   -123)
Int: (-000123)
Int: (-123000)

Actual Output:

Int: (-123)
Int: (   -123)
Int: (000-123)
Int: (-123000)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Buggeneral bugs; can be anything

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions