0

I'm looking for a literal which would convert scientific notation to a type other than double. In my case, i need uint64_t. It should do something like this:

uint64_t x = 1e6_ui64;

But I'm not sure if there is something already present in C++ or one of its standard libs.

Where can I find literals for scientific notation? Do they exist in C++? Or should I implement them myself?

Kaiyakha
  • 1,463
  • 1
  • 6
  • 19
  • 5
    There is no such standard suffixes, because there is no much sense in these. You need to implement your own if you really need it. – sklott Dec 07 '22 at 12:02
  • 1
    Maybe a simple `static_cast` would do the job (assuming the value is representable as an `uint64_t`). – Fareanor Dec 07 '22 at 12:24
  • It's probably more readable to use digit separators: `1'000'000`. – j6t Dec 07 '22 at 12:32
  • @j6t `1e6` is just an example, I also need it for numbers as big as `1e15` – Kaiyakha Dec 07 '22 at 12:56

0 Answers0