### "cout" a double with no decimals

Hi all!

I have a problem writing a double with no decimals. I know how to decrease decimals with setprecision and fixed.

for example

double one = 3.414, two = 3.514;

cout << one <" " <<two;

How to make the outcome 3 4?

thanks for any help at all!
`cout << std::setprecision(0) << one << " " <<two;`
thx! :)

it doesnÂ´t seem to work tho..?
works for me:
 ``123456789`` ``````#include #include int main() { double x = 2.44, y = 3.1123; std::cout << std::setprecision(0) << x << " " << y << std::endl; return 0; }``````
closed account (3TXyhbRD)
 ``12345678`` ``````#include #include int main() { double one = 3.414, two = 3.514; std::cout << std::setprecision(1) << one << ' ' << two << std::endl; }``````
closed account (3qX21hU5)
What doesn't work? Could you post the code you have so we can see whats wrong? Because it should work.
 ``1234567891011`` ``````#include #include int main () { double a = 3.414, b = 3.514 ; // std::llround(): round away from zero, to long long std::cout << std::llround(a) << " " << std::llround(b) << '\n' // 3 4 << std::llround( -a ) << " " << std::llround( -b ) << '\n' ; // -3 -4 }``````
Topic archived. No new replies allowed.