Skip to content

Precision for long double #3564

Description

@sukolenvo

Hi, here is sample code to reproduce the problem I struggle with:

#include <fmt/core.h>

int main(int argc, char ** argv) {    
    fmt::print("{:.2f}\n",  0.099f);
    fmt::print("{:.2f}\n",  0.099L);
    return 0;
}

Output is :

0.10
0.1

https://godbolt.org/z/rxMb5nEGP

Is there a reason why precision 2 is working differently for long double compared to float?

PS Output also vary by compiler:
clang 14, gcc 12 output is 0.1
vs 2022 output is 0.10

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions