How to split large numbers?

I have a large number (unsigned integer) stored in 2 variables (as you can see, with high and low part of the number):

unsigned long long int high;
unsigned long long int low;

I know how to add or subtract some other kind of variable.

But I need to divide such numbers. How to do it? I know I can subtract N times, but maybe there are better solutions .; -)

Language: C

+3
source share
9 answers

Yes. This will be due to changes, and I do not recommend doing it in C. This is one of those rare examples where assembler can still prove its worth by easily making things work hundreds of times faster (And I don't think I'm exaggerating this. )

, :

(1) .

(2) , , .

(3) .

(4) , , - . (3), . ( - " ", .)

REAL: -)

+6
+2

, N , , , .

N , N .

(.. , ) , , .

[ / .]

+2

. , "", , , , .

0

.

, , , , , , "", , , ( ).

, , , .

0
0

"BigInt", . 1 , . , , .

C, , , . , " ", .

0

, "add/subtract with carry (adc/sbb)". , . , , .

0

( C) 64- , 128- ( , 32- 16- ).

, , , , . ? , , .

, , , .

0

Source: https://habr.com/ru/post/1710861/


All Articles