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_sqrt.cpp
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
26 #ifndef __USE_VFP_MATH
28 #ifndef __REALS_MACHINE_CODED__
29 LOCAL_D const TUint32 KConstAdata[] = {0x00000000,0xD5A9A805,0x7FFD0000};
30 LOCAL_D const TUint32 KConstBdata[] = {0x00000000,0x9714B9CB,0x7FFE0000};
31 LOCAL_D const TUint32 Sqr2Invdata[] = {0xF9DE6484,0xB504F333,0x7FFE0000}; // 1/sqr2
36 EXPORT_C TInt Math::Sqrt(TReal& aTrg,const TReal &aSrc)
38 Calculates the square root of a number.
40 @param aTrg A reference containing the result.
41 @param aSrc The number whose square-root is required.
43 @return KErrNone if successful, otherwise another of
44 the system-wide error codes.
47 // Fast sqrt routine. See Software manual by W.J.Cody & W.Waite Chapter 4.
50 const TRealX& KConstA=*(const TRealX*)KConstAdata;
51 const TRealX& KConstB=*(const TRealX*)KConstBdata;
52 const TRealX& Sqr2Inv=*(const TRealX*)Sqr2Invdata;
61 if (r==KErrArgument || x.iSign&1)
66 if (r==KErrOverflow) // positive infinity
73 TRealX y=KConstB*x+KConstA;
85 y.iExp=TUint16(TInt(y.iExp)+(n>>1));
86 return y.GetTReal(aTrg);
90 #endif // !__USE_VFP_MATH - VFP version is in assembler