434,905 Members | 2,083 Online + Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,905 IT Pros & Developers. It's quick & easy.

Some questions, big numbers library

 P: n/a Hi, I've to implement fast library for big numbers arithmetics. I'll store the number in the table of unsigned long variables. And now i've a question: what will be faster: a) storing in one cell of the table values from 0 to 999999999 so for example number 1111222233334444 will look in table:   // <- i'm reversing the cell's order + using this method conversion number<->ascii string will be fast + the arithmetic (for example multiplication) will be slow (because for carrying detection i'll have to divide a lot by 1000000000) b) storing in one cell of the table values from 0 to (2^32)-1 (so all bit's combination). But in this method i have to change base from decimal to binary, which is too slow for very big numbers so for example number 1111222233334444 will look in table:   // <- this numbers are in binary + using this method conversion number<->ascii string will be slow + the arithmetic (for example multiplication) will be fast In my program i'm running a lot of arithmetic algorithms, and at the beginning i'm printing the result. I was thinking that second method will be much faster, but... Converting from number to ascii string takes a lot lot of time (when number has more than 100000 digits). Do anyone have fast base converting algorithm for very long numbers or should i use method a) ? Hope you have understand this... Greets&Thanks&Happy Easter peter_k Apr 16 '06 #1 