FIX: C code (double, float, ...) + wrapper (read/write data, get medoids)
[epclust.git] / code / stage1 / src / Util / utils.c
index efd4dd2..91ea075 100644 (file)
@@ -30,7 +30,7 @@ char readInt(FILE* stream, int64_t* integer)
        return curChar;
 }
 
-char readReal(FILE* stream, Real* real)
+char readReal(FILE* stream, float* real)
 {
        int64_t integerPart;
        char nextChar = readInt(stream, &integerPart);
@@ -51,8 +51,8 @@ char readReal(FILE* stream, Real* real)
        if (nextChar == 'e' || nextChar == 'E')
                nextChar = readInt(stream, &exponent);
        int64_t divisorForFractional = pow(10, floor(log10(fractionalPart > 0 ? fractionalPart : 1))+1);
-       *real = ( (Real)integerPart 
-               + (integerPart < 0 ? -1 : 1) * (Real)fractionalPart/(divisorForFractional*pow(10,countZeros)) )
+       *real = ( (float)integerPart 
+               + (integerPart < 0 ? -1 : 1) * (float)fractionalPart/(divisorForFractional*pow(10,countZeros)) )
                        * pow(10,exponent);
        return nextChar;
 }
@@ -79,7 +79,7 @@ void write_int(uint32_t x, Byte* buffer)
 
 //WARNING: assuming float is 32bits...
 // convert 4-bytes binary float to float
-float bReal_to_double(Byte* pFloat)
+float bReal_to_float(Byte* pFloat)
 {
        float res;
        memcpy(&res, pFloat, 4);
@@ -121,7 +121,7 @@ uint32_t get_nbSeries(const char* ifileName)
        if (lengthRead != 1)
                fprintf(stderr,"Warning: getting nbSeries from truncated binary file.\n");
        fclose(ifile);
-       return bInt_to_uint(binaryInt, 4);
+       return bInt_to_uint(binaryInt);
 }
 
 // get metadata: tsLength
@@ -134,5 +134,5 @@ uint32_t get_tsLength(const char* ifileName)
        if (lengthRead != 1)
                fprintf(stderr,"Warning: getting tsLength from truncated binary file.\n");
        fclose(ifile);
-       return bInt_to_uint(binaryInt, 4);
+       return bInt_to_uint(binaryInt);
 }