Compression that can be used with mpz_*_raw
David McKen
dmlmcken at comcast.net
Wed Jun 16 00:45:51 CEST 2004
Kevin Ryde wrote:
>David McKen <cic_3_b at yahoo.com> writes:
>
>
>>I have essentially reverse enginered the file format that is used by
>>mpz_*_raw
>>
>>
>
>You have the code and a complete description in the manual.
>
>
>
>>It seems there is an extra byte written after every number,
>>this byte has the value of '0A' in hex.
>>
>>
>
>No. If that's happening it's a bug.
>_______________________________________________
>gmp-discuss mailing list
>gmp-discuss at swox.com
>https://gmplib.org/mailman/listinfo/gmp-discuss
>
>
>
Ok, would anyone else mind checking my program to see if I am doing
something to get messed up results, if the program is correct then maybe
someone can verify that the bug exist on something other than 4.1.3
compiled using mingw on win 2000.
#include <cstdio>
#include <iostream>
#include <fstream>
#include <ctime>
using namespace std;
#include <gmpxx.h>
int main()
{
FILE * bin_file = fopen("raw_out.bin","wb");
ofstream txt_file("txt_out.txt", ios::out);
mpz_class current;
gmp_randstate_t state;
char buffer[5000];
gmp_randinit_default(state);
for(int i = 0; i < 10; i++)
{
mpz_urandomb (current.get_mpz_t(),state, 128);
gmp_sprintf (buffer, "%Zd\n%Zx\n\n", current.get_mpz_t(),
current.get_mpz_t());
txt_file << buffer << endl;
mpz_out_raw(bin_file,current.get_mpz_t());
fputc('\n',bin_file);
}
fclose(bin_file);
return 0;
}
-- end code, start txt_out.txt --
180923646377713599884174799784068830485
881ca077518c809013ae8ec6baecd515
214186364819188332769970305918441320756
a122cb1a323a76367ee78d71870b7134
125296593035471373346016073085341473089
5e433efcd960a1bf841fd60599811941
263312472575425093169242751699857816723
c61823378ca06de01c8b6fb148c9bc93
274915924093870141090274031071133009047
ced2e18bd88529bd2480e20191958497
145376625178005669689188276272328051767
6d5e85022ca2a2c383c28e85ad038c37
99677841991045221035464467438071768388
4afd410a9dd4b08cca7669c747cce544
88561328208547440951197334336108322460
42a04a989c5800528ef687c978355e9c
160507600827456697259588796748156906762
78c0a3b489a07b86ebca6adf96982d0a
309039985336946128519862079679639248785
e87eefa95179ca11bedcdf420eb6df91
-- end txt_out.txt, start hex dump of raw_out.bin --
00 00 00 10 88 1C A0 77 51 8C 80 90 13 AE 8E C6 BA EC D5 15 0A 00 00 00
10 A1 22 CB 1A 32 3A 76 36 7E E7 8D 71 87 0B 71 34 0A 00 00 00 10 5E 43
3E FC D9 60 A1 BF 84 1F D6 05 99 81 19 41 0A 00 00 00 10 C6 18 23 37 8C
A0 6D E0 1C 8B 6F B1 48 C9 BC 93 0A 00 00 00 10 CE D2 E1 8B D8 85 29 BD
24 80 E2 01 91 95 84 97 0A 00 00 00 10 6D 5E 85 02 2C A2 A2 C3 83 C2 8E
85 AD 03 8C 37 0A 00 00 00 10 4A FD 41 0A 9D D4 B0 8C CA 76 69 C7 47 CC
E5 44 0A 00 00 00 10 42 A0 4A 98 9C 58 00 52 8E F6 87 C9 78 35 5E 9C 0A
00 00 00 10 78 C0 A3 B4 89 A0 7B 86 EB CA 6A DF 96 98 2D 0A 0A 00 00 00
10 E8 7E EF A9 51 79 CA 11 BE DC DF 42 0E B6 DF 91 0A
--end raw_out --
More information about the gmp-discuss
mailing list