cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Remainder Command
Remainder Command
Jun 28, 2013 at 1:51pm UTC
GoranGaming
(128)
Is there a command to completely remove the remainder of a
double
variable type? I want as an example 12.96 to become 12, but it should be a general solution so I can't just remove 0.96 every time because the number won't be the same every time.
Jun 28, 2013 at 1:54pm UTC
Peter87
(11238)
Maybe you want std::fmod or std::remainder.
http://en.cppreference.com/w/cpp/numeric/math/fmod
http://en.cppreference.com/w/cpp/numeric/math/remainder
Jun 28, 2013 at 1:55pm UTC
maeriden
(872)
Casting to int truncates the fractional part - no rounding.
Jun 28, 2013 at 2:18pm UTC
GoranGaming
(128)
Don't worry, I found something that worked, the floor function :)
Last edited on
Jun 28, 2013 at 2:18pm UTC
Topic archived. No new replies allowed.