Float or double always gives answer in scientific notation if number of digits are 7 or more. Like an decimal number 10000000.5
it is giving 1e-08
something. I am wondering if we can print 10000000.5
without adding any new header file.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Do the Java Integer and Double objects have unnece
- Why does const allow implicit conversion of refere
- thread_local variables initialization
相关文章
- 关于C#中 float、double、decimal 的运算不精确的问题。
- How can I convert a f64 to f32 and get the closest
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
printf("%.1f", someFloat)
should do that for you, if you want one decimal digit. If you wantn
decimal digits, then use%.nf
If you are printing to
cout
, useSee it work.
You might also want
std::cout.precision(1)
to set the number of digits after the decimal point.