Skip to content

Wrong formatting of negative zero when sign is requested #24623

Closed
@nagisa

Description

@nagisa
use std::mem;
fn main() { 
    let neg_zero: f32 = unsafe { mem::transmute(0x8000_0000u32) };
    assert_eq!(format!("{:+}", neg_zero), "-0");
}

Fails with “assertion failed: (left == right) (left: "+0", right: "-0")”

playpen

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-floating-pointArea: Floating point numbers and arithmeticA-fmtArea: `core::fmt`C-bugCategory: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions