We have a school assignment and we were told that all numbers end after the
third decimal digit, meaning 0.0009 is 0 in our case.
How can I do that in c++?
Should I create a new class using operator overloading?
Thanks
We have a school assignment and we were told that all numbers end after
Share
That would help make the code that uses the class simple. It’s up to you to decide whether you want to make the effort to obtain that simplicity.
In C++ there is a way to truncate a floating point number to zero decimal places: a cast.
You can use this with some math to truncate to three decimal places.