Saturday 15 September 2012

Arithmetic With Precision

                                Arithmetic With Precision

Have you ever used C/C++. Tried to perform simple arithmetic operations on real numbers of considerably longer length. If yes, then you must have known that none of these languages provide you the answers with perfect precision. Even the same may be the case with java. So, here is the task. Just take two numbers (of course real), try to perform any arithmetic operation (+,-,/,*) and then try to simply print it on the console, but with infinite precision.


    987432189374581923.123276453
+ 199283777167383992.383477628
____________________________________________

Take care, answer should look like one of operands, without any exponential notation.

1 comment:

  1. Addition and Subtraction can be solved by taking the numbers as Linked Lists. Same goes for multiplication. Not sure about Division though.

    ReplyDelete