uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/huifixmath.h
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:   Fixed point arithmetics
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __HUIFIXMATH_H__
       
    21 #define __HUIFIXMATH_H__
       
    22 
       
    23 #include <e32def.h>
       
    24 
       
    25 static const TInt KFixPi = 0x3243F;
       
    26 
       
    27 
       
    28 class HuiFixMath
       
    29 {
       
    30 public:
       
    31     IMPORT_C static TUint FixHypot(TInt aVal1,TInt aVal2);
       
    32 		IMPORT_C static TInt FixSin(TInt aRadians);
       
    33 		IMPORT_C static TInt FixCos(TInt aRadians);
       
    34 		
       
    35 		static inline TInt FixMul(TInt aVal1, TInt aVal2);
       
    36 		static inline TInt FixDiv(TInt aVal1, TInt aVal2);
       
    37 		static inline TInt FloatToFix(TReal32 aVal);
       
    38 		static inline TReal32 FixToFloat(TInt aVal);
       
    39 };
       
    40 
       
    41 TInt HuiFixMath::FixMul(TInt aVal1, TInt aVal2)
       
    42 		{
       
    43 		TInt64 result = (TInt64(aVal1))*(TInt64(aVal2));
       
    44 		return TInt(result>>16); 
       
    45 		};
       
    46 
       
    47 TInt HuiFixMath::FixDiv(TInt aVal1, TInt aVal2)
       
    48 		{
       
    49 		TUint64 temp = aVal1;
       
    50 		temp<<=16;
       
    51 		return TInt(temp/aVal2);
       
    52 		};
       
    53 
       
    54 TInt HuiFixMath::FloatToFix(TReal32 aVal)
       
    55 		{
       
    56 		return TInt(aVal*65536.0f);
       
    57 		}
       
    58 		
       
    59 TReal32 HuiFixMath::FixToFloat(TInt aVal)
       
    60 		{
       
    61 		return TReal32((TReal32(aVal))/65536.0f);
       
    62 		}
       
    63 
       
    64 
       
    65 #endif