954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Arithmetic on character strings (char arrays)

So I'm trying to achieve this myself, but I decided to ask on this forum to see if anyone knew about some obscure project on sourceforge or something that did exactly this:

I need to store very large numbers and perform arithmetic on them. I am storing the values in a string of characters. The reason I am not using a bigint library is not only do I need something a little more tailored to my needs (I'm reading a binary file into an array of chars since I cant read it into any other variable, ifstream::read() ) I can't for the life of me figure out a way to copy the value stored in the char array into a bigint and I don't think the developers of the bigint libraries intended for them to be used that way.

And now to get to the point: I need a way to perform arithmetic on a string of chars,and I am working on it, but it's not working very well at the moment. Does anyone know if somebody else already made functions or designed a bigint library specifically for this?

Thanks

Mahkoe
Newbie Poster
9 posts since Nov 2010
Reputation Points: 6
Solved Threads: 0
 

>>I can't for the life of me figure out a way to copy the value stored in the char array into a bigint and I don't think the developers of the bigint libraries intended for them to be used that way.

The developer of bigint did indeed provide a function for input/output with standard streams (istream ostream) and you can easily use that to turn a char-array into a bigint and vice versa, using the std::stringstream class. See the BigIntegerUtils.hh file.

mike_2000_17
Posting Virtuoso
Moderator
2,139 posts since Jul 2010
Reputation Points: 1,634
Solved Threads: 457
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: