# VERY large numbers in multiplication

### » Sat Aug 31, 2013 9:30 am

------------Multiplication without multiplication----------------

Here the original
This guy is a monster in c++. You can watch his lessons even if you don't know Russian, because I'm know and don't understand him )))

It's hard to explain what I actually do in the code and more harder translate it.

As you can see it have two methods abot how make multipli using addition only (P.S. and one time subtraction)

HTML

Hre the C2's codeKurz2013-10-18 09:37:15
B
57
S
20
G
10
Posts: 191
Reputation: 9,686

### » Fri Oct 18, 2013 9:34 am

It's a old post, but right now I'm check the standart multiplication ("Multipli" button) between 6000000000*6000000000 (9 zeroes)- and C2 can't count it

BUT the "Fast" method in "Fast" button count 9000000000000 and 9000000000000 (12 zeroes)correctly

I'm confused !

B
57
S
20
G
10
Posts: 191
Reputation: 9,686

### » Sat Oct 19, 2013 3:34 pm

it would have probably been faster to use bit shifting rather than addition for
acc += acc
probably
acc = acc << 1
n = n << 1

The method he uses is still requiring the computer to addition. Which is fast, but bitshifting as the sample above litterally means acc += acc without the math. It bumps the bit's up.

Using a custom mathlib is common for the bleeding edge game engines. However it's not that simple of a job. Mostly the work isn't the math. It's that this form of math works best for INT32 and INT64 based math. The hurdle is handling FLOAT32 or FLOAT64 math operations.

He is using the model of doubling up. Once the add it's higher it's just a system of reducing the over amount by the remaining.

I remember hunting down a Java mathlibrary back when I was trying to do games in MIDP Java for mobile phones. before Smart Phone :D
B
94
S
18
G
9
Posts: 2,457
Reputation: 15,167