os/ossrv/genericopenlibs/liboil/tsrc/inc/utils.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/liboil/tsrc/inc/utils.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,67 @@
     1.4 +/*
     1.5 +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +#ifndef _UTILS_H__
    1.24 +#define _UTILS_H__
    1.25 +
    1.26 +#include <math.h>
    1.27 +
    1.28 +#define LEN 15
    1.29 +
    1.30 +int comparefloats(double symbian_op, double linux_op)
    1.31 +    {
    1.32 +    double fractpart1=0, intpart1=0, fractpart2=0, intpart2=0;
    1.33 +    int ret = 0;
    1.34 +    char str_int1[LEN+1] = "\0";
    1.35 +    char str_fract1[LEN+1+2] = "\0";
    1.36 +    char str_fract2[LEN+1+2] = "\0";
    1.37 +    char format_str[10] = "\0";
    1.38 +    int len1=0, len_to_comp=0;
    1.39 +    
    1.40 +    if((symbian_op < 0) && (linux_op < 0))
    1.41 +        {
    1.42 +        symbian_op = symbian_op * -1;
    1.43 +        linux_op = linux_op * -1;
    1.44 +        }
    1.45 +    
    1.46 +    fractpart1 = modf(symbian_op, &intpart1);
    1.47 +    fractpart2 = modf(linux_op, &intpart2);
    1.48 +    
    1.49 +    if(intpart1 == intpart2)
    1.50 +        {
    1.51 +        sprintf(str_int1, "%d", (int)intpart1);
    1.52 +        len1 = strlen(str_int1);
    1.53 +        
    1.54 +        len_to_comp = LEN - len1;
    1.55 +        sprintf(format_str, "%s%d%s", "%0.", len_to_comp, "f");
    1.56 +    
    1.57 +        sprintf(str_fract1, format_str, fractpart1);
    1.58 +        sprintf(str_fract2, format_str, fractpart2);
    1.59 +        
    1.60 +        if(strcmp(str_fract1, str_fract2) != 0)
    1.61 +            ret = 1;
    1.62 +        }
    1.63 +    else
    1.64 +        ret = 1;
    1.65 +    
    1.66 +    return ret;
    1.67 +    }
    1.68 +
    1.69 +#endif //_UTILS_H__
    1.70 +