28 int fread_be(
int* aa,
int size,
int nb, FILE* fich) {
36 bool little_endian = ( *(
reinterpret_cast<char*
>(&itest) ) == 1) ;
40 int size_tot = 4 * nb ;
42 char* bytes_big =
new char[size_tot] ;
44 int nr =
static_cast<int>(fread(bytes_big, 1, size_tot, fich)) ;
46 char* pbig = bytes_big ;
47 char* plit =
reinterpret_cast<char*
>( aa ) ;
49 for (
int j=0; j< nb; j++) {
51 for (
int i=0; i<4; i++) {
67 return static_cast<int>(fread(aa, size, nb, fich)) ;
76 int fread_be(
double* aa,
int size,
int nb, FILE* fich) {
84 bool little_endian = ( *(
reinterpret_cast<char*
>(&itest) ) == 1) ;
88 int size_tot = 8 * nb ;
90 char* bytes_big =
new char[size_tot] ;
92 int nr =
static_cast<int>(fread(bytes_big, 1, size_tot, fich)) ;
94 char* pbig = bytes_big ;
95 char* plit =
reinterpret_cast<char*
>( aa ) ;
97 for (
int j=0; j< nb; j++) {
99 for (
int i=0; i<8; i++) {
100 plit[i] = pbig[7-i] ;
108 delete [] bytes_big ;
115 return static_cast<int>(fread(aa, size, nb, fich)) ;