Construction From vector<char> ?

Robert Evans bobsphysics at yahoo.com
Thu Aug 14 00:20:44 CEST 2008


Thanks Marc - exactly what I need.  I was poking around the documentation for the C++ interface and did not see this.  We use vector<char> for "historical" reasons, the rationale I'm not aware of.

 Bob


----- Original Message ----
From: Marc Glisse <marc.glisse at normalesup.org>
To: Robert Evans <bobsphysics at yahoo.com>
Cc: gmp-discuss at swox.com
Sent: Wednesday, August 13, 2008 4:31:00 PM
Subject: Re: Construction From vector<char> ?

On Wed, 13 Aug 2008, Robert Evans wrote:

> Sorry, I am not explaining myself well.  What we have is not a vector
> containing the characters (i.e. ascii) representing a number, but the
> actual hex bytes.  For example, we might have a 4 byte array containing
> [0x31 0x32 0x33 0x34].  For us this is NOT the number "1234" but the
> number 0x31323334 or in decimal 825373492.  I supposed we should have
> used the name vector<unsigned short> but someone used vector<char> which
> is a bit  misleading.

Wow ok. The most confusing thing is that the smallest the type you put in 
vector, the slower the computations on that number will be. I just 
couldn't believe that someone would use char there...

Then what you are looking for is most likely mpz_import/mpz_export.

-- 
Marc Glisse



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gmplib.org/list-archives/gmp-discuss/attachments/20080813/0b78fd96/attachment-0001.html 


More information about the gmp-discuss mailing list