Greetings everybody,
i have a few basic questions about using math in a computer program and i hope to get some help.
I'm aware that some or all questions may be stupid and i might blame myself, but i have not figured out the answers on my own, and asking google doesn't help either. (An 'i think' chinese proverb says: the fool who asks stays a fool for some time, the fool who does not ask stays a fool forever)
So i post my questions here, because i believe in this forum are people who do know a lot about math.
// I usally use C/C++ on a 32-bit computer;
When it comes to programming and math, i'm interested in two things most:
Primes and taxicab numbers.
I will start with taxicab first (if you don't know what this is, you might get a start here: http://euler.free.fr/taxicab.htm
i have a 32-bit computer, so i assume i can use up to 2^32 bit of address space, basically 4 GB;
I know that _int64 exists, so i can use numbers up to 2^64 (sometimes called long).
Question 1:
How is this done on a 32-bit machine? I think that my registers (like AX, BX, CX or even EAX and so on) are 32-bit also, which comes to 2 possible explanations:
- other registers are used, like the FPU
- there is a way to 'connect' registers (asm?), but how does it work? I think i might know howto with add, sub, maybe even mul, but what about div ?
How often can i 'connect' a register ?
Question 2:
I can perform add, sub, mul on a 'digit-per-digit' base.
Is there a way to do a div digit-per-digit, too?
For div, i only know to do a loop with subs until i get number1:number2 = something (mod someotherthing) - that doesn't work like intended, of course, if number2 is 'too big'
Question 3:
For the taxicab problem, i would need a _int128. Any chance to program it myself without using a BigInt lib or writing a LARGEINT class using char *? (My compilers doesn't have _int128, only _int64)
(Note: BigInt refers to a lib downloaded from the internet, which i might not understand - and i would like to learn the 'stuff behind it' while LARGEINT refers to my own code using 'strings' to achieve arbitrary large numbers (>> int) - which is so slow)
Question 4:
I have written my own LARGEINT class using 'strings'. While i might be able to actually check the largest known prime, i think im stuck at 2^32 anyway. Right or wrong? This question goes specifically to a C/C++ program using
char *temp = new char[SIZE] for the number in question;
(I know i could somehow go down to bits and achieve 2^32 * 8 but there is still a limit)
Question 5:
Sob is calculation insane big numbers. Some of these numbers are sieved.
How is this be done ? How so fast? What is 'sieve' exactly doing? Is it sieving every possible number starting with the lowest or just 'some' numbers?
I would greatly appreciate any form of input, be it written here or linked from somewhere. What i would hope to get is specific and usable information, not something like: just check www.wikipedia.org and insert your question into search. I tried before.
Regards,
Chris