|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef _UTILS_H__ |
|
21 #define _UTILS_H__ |
|
22 |
|
23 #include <math.h> |
|
24 |
|
25 #define LEN 15 |
|
26 |
|
27 int comparefloats(double symbian_op, double linux_op) |
|
28 { |
|
29 double fractpart1=0, intpart1=0, fractpart2=0, intpart2=0; |
|
30 int ret = 0; |
|
31 char str_int1[LEN+1] = "\0"; |
|
32 char str_fract1[LEN+1+2] = "\0"; |
|
33 char str_fract2[LEN+1+2] = "\0"; |
|
34 char format_str[10] = "\0"; |
|
35 int len1=0, len_to_comp=0; |
|
36 |
|
37 if((symbian_op < 0) && (linux_op < 0)) |
|
38 { |
|
39 symbian_op = symbian_op * -1; |
|
40 linux_op = linux_op * -1; |
|
41 } |
|
42 |
|
43 fractpart1 = modf(symbian_op, &intpart1); |
|
44 fractpart2 = modf(linux_op, &intpart2); |
|
45 |
|
46 if(intpart1 == intpart2) |
|
47 { |
|
48 sprintf(str_int1, "%d", (int)intpart1); |
|
49 len1 = strlen(str_int1); |
|
50 |
|
51 len_to_comp = LEN - len1; |
|
52 sprintf(format_str, "%s%d%s", "%0.", len_to_comp, "f"); |
|
53 |
|
54 sprintf(str_fract1, format_str, fractpart1); |
|
55 sprintf(str_fract2, format_str, fractpart2); |
|
56 |
|
57 if(strcmp(str_fract1, str_fract2) != 0) |
|
58 ret = 1; |
|
59 } |
|
60 else |
|
61 ret = 1; |
|
62 |
|
63 return ret; |
|
64 } |
|
65 |
|
66 #endif //_UTILS_H__ |
|
67 |