Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uint8_t formatted as a character by default #217

Closed
Nekotekina opened this issue Oct 31, 2015 · 3 comments
Closed

uint8_t formatted as a character by default #217

Nekotekina opened this issue Oct 31, 2015 · 3 comments

Comments

@Nekotekina
Copy link

Hi!

Was it indended that the value of std::uint8_t type becomes a character if formatted as {}? It was slightly confusing.

@vitaut
Copy link
Contributor

vitaut commented Nov 1, 2015

Hi, @Nekotekina.

No, this is not intentional, but an unfortunate consequence of std::uint8_t being defined as unsigned char. It might be worth changing the default format of unsigned char and signed char to numeric, but other potentially undesirable side-effects must be considered.

In the meantime you can format std::uint8_t using a numeric format specifier such as d:

  std::uint8_t u = 42;
  fmt::format("{:d}", u);

or promoting the argument to int:

  fmt::format("{}", +u);

@vitaut
Copy link
Contributor

vitaut commented Nov 6, 2015

Fixed in 7c24973.

@vitaut vitaut closed this as completed Nov 6, 2015
@Nekotekina
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants