Handling very large numbers without using scientific notation
BB4W, like most programming languages, can handle very large numbers - but only in floating-point notation. This is fine for normal usage, but what if you want to investigate the digits of such a number? For instance, you may be looking for patterns in the digits such as a sequence or groupings of similar digits (there are still folk out there looking for patterns in pi, out at the millionth decimal place!).
The program below can multiply very large numbers together and show the exact answer with every digit present. I hope no-one is offended by the copyright notice in there. You're free to use the code without obligation, but please acknowledge me if you use it in released work. I've had the experience of having code stolen, slightly altered, and then being claimed as the work of the person doing the alteration. Anyway, here it is:
string_multiplication_2.bbcString Multiplication _2.bbc
- 2 KB
I hope this is useful to someone out there.
Edit by Richard Russell, December 2013
See also the MAPM (My Arbitrary Precision Math) and HIME (Huge Integer Math and Encryption) libraries, both of which support calculations using arbitrary precision integer arithmetic:
BB4WMAPMLIB is here
HIMELIB is here