0

Hello everyone! :)

Here I come to you again with a question.
I need some ideas on how make a java program that can work with big numbers, without using special java API`s like java.util.BigInteger and java.util.BigDecimal. This program will be able to substract and concatenate.

My idea would be to declare the numbers in a string, then convert each character starting from the last position to a int and concatenate it. If the number would exceed 9 a variable called catch will get the value 1. The result would be added to a StringBuilder.

So what do you think is my idea doable or i need to rethink the implementation of this program?

Thanks in advance. :icon_mrgreen:

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by JamesCherrill
0

Sounds reasonable. Maybe an array of chars rather than a String to make it easier to access and update individual digits? Don't forget that the char '9' is number whose value is not 9!
Make a start by writing the class, instance variables, and method signatures. Sketch out how the methods will work with a few comments. Write the constructor(s) and the toString() methods. Test them with a main(...) method. Then fill in the code for the other methods, testing as you go (lots of System println statements).
You can do this in a different order if you like, but it will take longer in the end.
Let us know how you get on?
J

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.