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

docs: update literals introduction with C++23 standard information #907

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions concepts/literals/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ auto net_worth_carlisle_cullen{46'000'000'000LL}; // int and uint are not enough
Floating-point numbers usually resolve to `double` during compilation.
This is a good default case and use-cases with the narrower `float` type are less frequent than the unsigned example above.

~~~~exercism/advanced
The [C++23 standard][cpp23-literals] introduces more fine grained control with literals like `f128` or `F16`.
Some compilers allow their own literals.
GCC permits the usage of `d` as a literal, but this is not forseen in the standard and can hinder cross-platform compatibility.
vaeng marked this conversation as resolved.
Show resolved Hide resolved

[cpp23-literals]: https://en.cppreference.com/w/cpp/language/floating_literal

~~~~

```cpp
auto light_year_in_m{9.46073e+15f}; // well in the range of float
auto earth_to_edge_comoving_distance_in_nm{4.32355e+32}; // needs double type for magnitude
Expand Down