• Create Account

We're offering banner ads on our site from just \$5!

#Actualkloffy

Posted 08 January 2013 - 05:31 PM

I am hacking together a quick implementation of a rudimentary big number library. I am aware that there are plenty of those around, but mine is for a very specific purpose (I want it to work under the restrictions of C++ AMP). Besides, I figured that it would be a good exercise.

So, all of my arithmetic operations work (using basic textbook long multiplication and division). However, I am starting to get tired of thinking in binary. I would like to output my numbers in decimal digits. For integers, I have just implemented the naive approach.
str = "";
num = x;
do {
digit = num%base;
num = num/base;
str = to_char(digit) + str;
} while (num>0);


Edit: Uhm, not sure where the rest of this went. Basically, my question was how to do the same for fixed point decimal numbers. I described an overly complicated solution and Álvaro whipped up the right answer straight away.

#4kloffy

Posted 08 January 2013 - 05:29 PM

I am hacking together a quick implementation of a rudimentary big number library. I am aware that there are plenty of those around, but mine is for a very specific purpose (I want it to work under the restrictions of C++ AMP). Besides, I figured that it would be a good exercise.

So, all of my arithmetic operations work (using basic textbook long multiplication and division). However, I am starting to get tired of thinking in binary. I would like to output my numbers in decimal digits. For integers, I have just implemented the naive approach.
str = "";
num = x;
do {
digit = num%base;
num = num/base;
str = digit + str;
} while (num>0);


Edit: Uhm, not sure where the rest of this went. Basically, my question was how to do the same for fixed point decimal numbers. I described an overly complicated solution and Álvaro whipped up the right answer straight away.

#3kloffy

Posted 08 January 2013 - 05:28 PM

I am hacking together a quick implementation of a rudimentary big number library. I am aware that there are plenty of those around, but mine is for a very specific purpose (I want it to work under the restrictions of C++ AMP). Besides, I figured that it would be a good exercise.

So, all of my arithmetic operations work (using basic textbook long multiplication and division). However, I am starting to get tired of thinking in binary. I would like to output my numbers in decimal digits. For integers, I have just implemented the naive approach.

str = "";
num = x;
do {
digit = num%base;
num = num/base;
str = digit + str;
} while (num>0);


Edit: Uhm, not sure where the rest of this went. Basically, my question was how to do the same for fixed point decimal numbers. I described an overly complicated solution and Álvaro whipped up the right answer straight away.

#2kloffy

Posted 08 January 2013 - 05:24 PM

I am hacking together a quick implementation of a rudimentary big number library. I am aware that there are plenty of those around, but mine is for a very specific purpose (I want it to work under the restrictions of C++ AMP). Besides, I figured that it would be a good exercise.

So, all of my arithmetic operations work (using basic textbook long multiplication and division). However, I am starting to get tired of thinking in binary. I would like to output my numbers in decimal digits. For integers, I have just implemented the naive approach.
str = "";
num = x;
do {
digit = x/base;
str = digit + str;
x=num;
} while(x>0);


Edit: Uhm, not sure where the rest of this went. Basically my question was how to do the same for fixed point decimal numbers.

#1kloffy

Posted 08 January 2013 - 05:05 PM

I am hacking together a quick implementation of a rudimentary big number library. I am aware that there are plenty of those around, but mine is for a very specific purpose (I want it to work under the restrictions of C++ AMP). Besides, I figured that it would be a good exercise.

So, all of my arithmetic operations work (using basic textbook long multiplication and division). However, I am starting to get tired of thinking in binary. I would like to output my numbers in decimal digits. For integers, I have just implemented the naive approach.
str = "";
num = x;
do {
digit = x%base;
str = digit + str;
x=num;
} while(x>0);


PARTNERS