Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / add 2 strings together!

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Apr 2007 11:43 Edited at: 25th Apr 2007 21:04
Want to add some really big numbers together that just won't fit within the Integer range? This snippet adds two really large numbers together by representing them as strings. Note that it probably only works with postive numbers.




Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 25th Apr 2007 18:59
This is really usefull.
its more exact than

answer$=str$(val(a$)+val(b$))

Nice function.

[/center]
Lucy
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 25th Apr 2007 19:20
Yay bignums!

No matter where you are... everyone is always connected.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Apr 2007 21:02 Edited at: 26th Apr 2007 06:53
It was actually your DBP post Lucy that made me want to try and write the function in the first place.


zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 25th Apr 2007 22:23
really cool Phaelax!!! Nice thinking outside the box.

I never had to approach this subject, but my initial guess would have been to make the large a number a "false" floating point. And then extract out the floating point on the result of the addtion. Haven't tried it though. And it seems your code would work for even larger numbers.

Login to post a reply

Server time is: 2024-11-22 18:50:53
Your offset time is: 2024-11-22 18:50:53