c - What is an efficient way to convert a bignum type structure to a human readable string? -


i've got bit of problem. in order grow in knowledge of c, i've decided try implement basic bigint library.

the core of bigint structure array of 32 bit integers, chosen because fit in register. allow me operations between digits overflow in 64 bit integer (which fit in register, i'm on x86-64), , can bitshift out each part of result. i've implemented basic addition, , test working, have print array. own testing purposes, it's fine if use printf() , output each digit in hex. can read fine.

however, people can't read hex. number stored in (essentially) base 2^32, printing bit of problem. way convert base 10?

edit:

this deals not knowing how convert base base, way implement this. thinking along lines of making bigint base conversion printing.

first of all, can't i/o in sensible way without basic operations(e.g. division , modulus). provide efficient implementation of converting bigint base-10 string, researching 2 possible optimizations:

first, can divide power of ten instead of ten exactly. means, 4 base-10 digits every time divide number 10000 example.

second, how choose power of ten divide by? 10, 100, 1000, 10000, etc...
there seems choice maximum power of ten can fit in word(32-bit). fortunately, can implement division/modulus 1 word more efficiently when comes 2 "bigint"s.

i haven't given implementation because still researching problem in spare time because have implemented basic operations in library , i/o next step ;)


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -