Hi everyone!
I'm reading a book and doing some exercises in this book. One of them is: define a class, which implements arithmetic (+, -, /, *) with arbitrary precision. This is a new type with just some arithmetic operations. With type double we also can do some arithmetic but with a definite precision.
May someone get me started. I need an idea to get into.
Thanks in advanced!
svatstika
0
Newbie Poster
Recommended Answers
Jump to PostFirst you need to be able to represent data in arbitrary length. One way to do that is use a std::vector<int> numbers or even std::string. Personally, I would choose the std::strings, because its easier to work with.
So lets define such a type :
class Number{ …
Jump to PostNo the point is to work with each digit in the string, not convert the string into a double..
All 7 Replies
alexchen
-12
Junior Poster
alexchen
-12
Junior Poster
alexchen
-12
Junior Poster
mrnutty
761
Senior Poster
svatstika
0
Newbie Poster
mrnutty
761
Senior Poster
svatstika
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.