Multiply 2 Arrays of Int

Hey Guys,
I´m working on a clicker game, which uses an array of ints for numbers, because I won´t limit my game with int.
1st int in array is for comma, 2nd for hundred, 3rd for thousand, 4th for million, 5th for billion, etc.

The math for add and subtract is finished, but with multiply I have problems…

Could anyone help me?

If the number is “123,456.78”, the arrays ints are this:
1st int = 78, 2nd int = 456, 3rd int = 123

Because int is limited to 2147483647 (about 2 billion), if you use comma in the same amount, it goes only to about 21 million and my numbers are higher than this value (float isn´t really accurate with high numbers)

Yeah, ints can´t have commas, but I´ve never said, taht the first integer in the array is as comma, it´s the amount of the comma as int^^

11.22 = 22 and 11

1,222.33 = 33 and 222 and 1

111,222,333,444.55 = 55 and 444 and 333 and 222 and 111

Only ints, if you add 11,222.33 to 22,333.55 the sum is 33,555.88 or in array 88 and 555 and 33

Do you have ever played an mmo with gold, silver and copper?
It´s the same number system.
But the amount of items in those mmos are limited to an amount of about 100, maybe because they have the same problem like me…

So … when this is now fully clarified, why I have chosen this numbers system, how can I multiply 2 Arrays of int?

Why are you storing the numbers like that, I don’t understand what you’re trying to achieve ?

You said “If the number is “123,456.78”, the arrays ints are…”, except integers don’t have commas. That’s what floats are for. So that “.78” shouldn’t be there in the first place if you’re only multiplying int variables.

But I guess you could truncate it (or floor/ceil it).

I highly doubt you’ll be handling numbers that might make a float not accurate enough to use.

Even if so - you’d probably be off by a tiny fraction, which may not mean much in most cases.

Going with floats will probably work just fine, and even if you do spot some bugs along the way - they would probably be a lot easier to fix than diving back into this logic.

Also, if your value represents the amounts of multiple, different things (gold/silver/copper) - why not use stand-alone variables? One per type of item.

If you want to represent their sum as a single number - it can be achieved via a rather simple calculation, or even via string manipulations, your call.

You can even wrap this entire bad boy as a struct & go wild.
In any case, I imagine it would be much easier than reinventing the float.

Amount limits in MMOs probably have nothing to do with data type limitations.

Aside from the elephant in the room, here is the solution.
let numbers be composed as a1,a2.a3 and b1,b2.b3 and the result be r1,r2.r3

r1 = a11000(b11000 + b2 + b30.01)/1000

r2 = a2*(b11000 + b2 + b30.001)

r3 = a30.01(b11000 + b2 + b30.01)/0.01

Note that this will not help anything if you are going through with this because you don’t want floating errors. If you want to do it properly i recommend you to delve into the C++ and create/use uint64 or uint128.

Thanks, I want try this, C++ is no option for me^^