How do I convert double 1.00 into int 1?
How do I convert double 1.00 into int 1?
I'm not sure if this is correct, but why not use static_cast<int>(1.00). I'm not sure if it's written correctly, but it changes the double into an integer.
Yeah, the static_cast as suggested by getName(C-Dub) is preferred to the C-style cast syntax as in mikeman118's example.
It is probably safe to cast 1.00 to 1, but note that more generally it may be possible that what looks like an integer when printed may be less than that integral value, thus the truncation when casting to int may result in an integer smaller than expected.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)