mpz_export question

Robert Evans bobsphysics at yahoo.com
Thu Aug 21 17:26:47 CEST 2008


I am trying to understand the behavior of mzp_export.  The following code snippet displays the resulting exported array.  If I start with 0 and increment, I get the arrays I would expect: [0x0 0x0...] [0x1 0x0...] [0x2 0x0...].  If I decrement from 0 I get: [0x0 0x0...] [0x1 0x0...], i.e., the identical arrays!
Can anyone shed light on what's going on?
Thanks, Bob

int main(void)
    {
    mpz_class x;
    x = "0x0";
    unsigned char result[ArraySize];
    memset ( result, 0, ArraySize );
    for (int j = 0; j < 5ArraySize j++ )
        {
        mpz_export (result,
                    NULL,   // number of words produced
                    1,      // order
                    1,      // word size
                    0,      // use native endianness
                    0,      // "nails" - produce full "words"
                    x.get_mpz_t()
            );
        cout << "---------------------------" << endl;
        for (int i = 0; i < ArraySize; i++)
            {
            cout << "result[" << i << "] = " << hex << (int)result[i] << endl;
            }
        x -= 1;
        }
    return 0;
    }


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gmplib.org/list-archives/gmp-discuss/attachments/20080821/4d1e8f8a/attachment.html 


More information about the gmp-discuss mailing list