gmp.h questions

Z

Zero

Hi,

I've been using gmp.h in my c programs. Here are the questions:

1) Is there any way to restrict the size of such variabls as mpz_t a;
to (for example) 128 bits?

2) What is the equivalence of ntohl() or htonl() in the gmp.h? If
there aren't anything like this, what can I do to turn the numbers to
big/little endian?

Thanks,
 
T

Tristan Miller

Greetings.

I've been using gmp.h in my c programs. Here are the questions:

That doesn't look like a standard C header. Since only standard C is
discussed here, perhaps you'd have better luck asking in a newsgroup
devoted to the particular compiler or library you're trying to use.
 
M

Michel Bardiaux

Zero said:
Hi,

I've been using gmp.h in my c programs. Here are the questions:

Please visit http://www.swox.com/gmp/ where you will find tons of doc,
and all the mailing lists related to GMP. Please subscribe there, it
would be a bad idea to continue this conversation here.
1) Is there any way to restrict the size of such variabls as mpz_t a;
to (for example) 128 bits?

You cant for mpz and mpq. You can for mpf, i.e. 'floating point'. If you
think about it you will see that 'restricted size' unavoidably leads to
'floating point'.
2) What is the equivalence of ntohl() or htonl() in the gmp.h? If
there aren't anything like this, what can I do to turn the numbers to
big/little endian?

(1) Given the above, will you be using mpz, mpq or mpf? (2) See the doc
about 'integer functions/IO', you will see the 'raw binary output
format' Since that is a sequence of native 32-bit numbers, you might
(and probably should) apply nthol/htonl the size and to each limb. Note,
however, that the order of *limbs* is always most-significant-first.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,082
Messages
2,570,589
Members
47,212
Latest member
JaydenBail

Latest Threads

Top