RE: gui calculator 10-24-2016, 04:37 AM
#2
Nice Project, but here are some recs which will get you pretty far and let you learn alot about how programming works:
make the program so that it will add/subtract unlimited lengths of numbers. An int can only hold 32bits, or 4bytes ( I think, this is what an int holds in Java, correct me if i'm wrong) regardless, an int has a cap on how large of a number it can store. So, for large calculations this is obviously not good.
How about storing the number in a string as it comes in, this means you can store a much larger number. Then, implement a function that will add/subtract. Basically, you're 'implementing' addition and subtraction.
Maybe that makes sense maybe it doesn't. Essentially it's this:
you have a string "1235472364832327432643289464573261"
and another string "384627395074369850846284070978473"
the first question you need to ask is, how do you add/subtract in real life?
well, ya go number by number
1+3 = 4, got it, store that 4 in a string which will be your sum (in such a way that you can add numbers before it.) Maybe a String isn't your best option maybe you can think of something better, but a String would work. It cannot be an int, because an int would be too small to hold the added number.
6+7 = 13 --> here's a problem, because if you put thirteen in as the number, it's not going to add right, so you have to carry over the one. This is where it gets interesting. This also reveals a bit about how a computer's CPU works. There's actually a circuit that needs to deal with carrying over digits.
Hope my suggestion helps~~~
I think you'll be able to figure it out
make the program so that it will add/subtract unlimited lengths of numbers. An int can only hold 32bits, or 4bytes ( I think, this is what an int holds in Java, correct me if i'm wrong) regardless, an int has a cap on how large of a number it can store. So, for large calculations this is obviously not good.
How about storing the number in a string as it comes in, this means you can store a much larger number. Then, implement a function that will add/subtract. Basically, you're 'implementing' addition and subtraction.
Maybe that makes sense maybe it doesn't. Essentially it's this:
you have a string "1235472364832327432643289464573261"
and another string "384627395074369850846284070978473"
the first question you need to ask is, how do you add/subtract in real life?
well, ya go number by number
1+3 = 4, got it, store that 4 in a string which will be your sum (in such a way that you can add numbers before it.) Maybe a String isn't your best option maybe you can think of something better, but a String would work. It cannot be an int, because an int would be too small to hold the added number.
6+7 = 13 --> here's a problem, because if you put thirteen in as the number, it's not going to add right, so you have to carry over the one. This is where it gets interesting. This also reveals a bit about how a computer's CPU works. There's actually a circuit that needs to deal with carrying over digits.
Hope my suggestion helps~~~
I think you'll be able to figure it out
![Wink Wink](https://sinister.ly/images/smilies/set/wink.png)
(This post was last modified: 10-24-2016, 04:40 AM by insidious.)
![[Image: pBD38Xq.png]](http://i.imgur.com/pBD38Xq.png)
Email: insidious@protonmail.ch