read an array from a file

Alexey Beshenov al at beshenov.ru
Wed Nov 28 01:12:13 CET 2007


On Tuesday 27 November 2007 15:21, Marius Neagoe wrote:

>   I work on a project about nonlinearity and I work with huge numbers.I use
> GMP library for processing these numbers. I need to know how to read an
> array that contains huge numbers from a file.Can you give me an example
> please?

Simple and portable solution is to write numbers as strings (in base 2^n---the 
best solution is to use base 32) line-by-line and then read them 
line-by-line.

The other solution (if you need to do I/O faster) is to write raw binary data 
with mpz_out_raw / mpz_inp_raw. See standard tips'n'tricks for binary 
serialization.

-- 
Alexey Beshenov <al at beshenov.ru>
http://beshenov.ru/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://gmplib.org/list-archives/gmp-discuss/attachments/20071128/14f88655/attachment.bin 


More information about the gmp-discuss mailing list