Update contrib.
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\euser\maths\um_frac.cpp
15 // Writes the fractional part of aTrg to aSrc
21 #if defined(__USE_VFP_MATH) && !defined(__CPU_HAS_VFP)
22 #error __USE_VFP_MATH was defined but not __CPU_HAS_VFP - impossible combination, check variant.mmh
25 #ifndef __USE_VFP_MATH
27 #ifndef __REALS_MACHINE_CODED__
28 EXPORT_C TInt Math::Frac(TReal &aTrg,const TReal &aSrc)
30 Calculates the fractional part of a number.
32 The fractional part is that after a decimal point.
33 Truncation is toward zero, so that
34 Frac(2.4)=0.4, Frac(2)=0, Frac(-1)=0, Frac(-1.4)=0.4.
36 @param aTrg A reference containing the result.
37 @param aSrc The number whose fractional part is required.
39 @return KErrNone if successful, otherwise another of
40 the system-wide error codes.
47 if (ret==KErrArgument)
49 if (ret==KErrOverflow)
50 SetZero(aTrg,f.iSign&1);
53 TInt intbits=f.iExp-0x7FFE;
54 if (intbits<=0) // aSrc is already a fraction
59 if (intbits>KMantissaBits)
61 SetZero(aTrg,f.iSign&1);
65 // calculate integer part and subtract
66 // this means that the subtraction normalises the result
69 TUint64 mask = ~(UI64LIT(0));
70 mask <<= (64 - intbits);
72 g.iMantHi &= static_cast<TUint32>(mask >> 32);
73 g.iMantLo &= static_cast<TUint32>(mask);
80 #endif //__REALS_MACHINE_CODED__
82 #else // __USE_VFP_MATH
84 // definitions come from RVCT math library
85 extern "C" TReal modf(TReal,TReal*);
87 EXPORT_C TInt Math::Frac(TReal& aTrg, const TReal& aSrc)
89 if (Math::IsNaN(aSrc))
94 if (Math::IsInfinite(aSrc))
101 aTrg = modf(aSrc,&temp);