First public contribution.
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\us_gcc.cpp
23 EXPORT_C TInt64 __fixsfdi(TReal32 a1)
25 // Convert float to long long
33 } // end of extern "C" declaration
35 #ifndef __REALS_MACHINE_CODED__
36 LOCAL_C void MathException(TInt aErrType)
38 // Decides on type of maths exception according to error and raises exception.
39 // Added by AnnW, December 1996
43 TExcType excType=EExcGeneral;
47 case KErrArgument: // error due to invalid operation
48 excType=EExcFloatInvalidOperation;
50 case KErrDivideByZero:
51 excType=EExcFloatDivideByZero;
54 excType=EExcFloatOverflow;
57 excType=EExcFloatUnderflow;
60 // also errors due to inexact result
61 case KErrInexact: // const not defined yet
62 excType=EExcFloatInexact;
68 Panic(EMathUnknownError);
71 User::RaiseException(excType);
74 EXPORT_C TReal32 __addsf3(TReal32 a1,TReal32 a2)
85 x1.Add(res,x2); // need not check error because no underflow and others will not be lost in conversion
86 TInt ret=res.GetTReal(trg);
93 EXPORT_C TReal64 __adddf3(TReal64 a1,TReal64 a2)
104 x1.Add(res,x2); // need not check error because no underflow and others will not be lost in conversion
105 TInt ret=res.GetTReal(trg);
112 EXPORT_C TReal32 __subsf3(TReal32 a1,TReal32 a2)
114 // Subtract two floats
123 x1.Sub(res,x2); // need not check error because no underflow and others will not be lost in conversion
124 TInt ret=res.GetTReal(trg);
131 EXPORT_C TReal64 __subdf3(TReal64 a1,TReal64 a2)
133 // Subtract two doubles
142 x1.Sub(res,x2); // need not check error because no underflow and others will not be lost in conversion
143 TInt ret=res.GetTReal(trg);
150 EXPORT_C TInt __cmpsf3(TReal32 a1,TReal32 a2)
152 // Compare two floats
165 EXPORT_C TInt __cmpdf3(TReal64 a1,TReal64 a2)
167 // Compare two doubles
180 EXPORT_C TInt __eqsf2(TReal32 a1,TReal32 a2)
182 // Compare if two floats are equal
188 return (x1==x2 ? 0 : 1);
191 EXPORT_C TInt __eqdf2(TReal64 a1,TReal64 a2)
193 // Compare if two doubles are equal
199 return (x1==x2 ? 0 : 1);
202 EXPORT_C TInt __nesf2(TReal32 a1,TReal32 a2)
204 // Compare if two floats are not equal
210 return(x1!=x2 ? 1 : 0);
213 EXPORT_C TInt __nedf2(TReal64 a1,TReal64 a2)
215 // Compare if two doubles are not equal
221 return(x1!=x2 ? 1 : 0);
224 EXPORT_C TInt __gtsf2(TReal32 a1,TReal32 a2)
226 // Compare if one float is greater than another
232 return(x1>x2 ? +1 : -1);
235 EXPORT_C TInt __gtdf2(TReal64 a1,TReal64 a2)
237 // Compare if one double is greater than another
243 return(x1>x2 ? +1 : -1);
246 EXPORT_C TInt __gesf2(TReal32 a1,TReal32 a2)
248 // Compare if one float is greater than or equal to another
254 return(x1>=x2 ? 1 : -1);
257 EXPORT_C TInt __gedf2(TReal64 a1,TReal64 a2)
259 // Compare if one double is greater than or equal to another
265 return(x1>=x2 ? 1 : -1);
268 EXPORT_C TInt __ltsf2(TReal32 a1,TReal32 a2)
270 // Compare if one float is less than another
276 return(x1<x2 ? -1 : +1);
279 EXPORT_C TInt __ltdf2(TReal64 a1,TReal64 a2)
281 // Compare if one double is less than another
287 return(x1<x2 ? -1 : +1);
290 EXPORT_C TInt __lesf2(TReal32 a1,TReal32 a2)
292 // Compare if one float is less than or equal to another
298 return(x1<=x2 ? -1 : +1);
301 EXPORT_C TInt __ledf2(TReal64 a1,TReal64 a2)
303 // Compare if one double is less than or equal to another
309 return(x1<=x2 ? -1 : +1);
312 EXPORT_C TReal32 __mulsf3(TReal32 a1,TReal32 a2)
314 // Multiply two floats
323 TInt ret=x1.Mult(res,x2);
324 if (ret==KErrNone) // must check this because if underflow, error is lost in conversion
325 ret=res.GetTReal(trg);
329 return((TReal32)res);
332 EXPORT_C TReal64 __muldf3(TReal64 a1,TReal64 a2)
334 // Multiply two doubles
343 TInt ret=x1.Mult(res,x2);
344 if (ret==KErrNone) // must check this because if underflow, error is lost in conversion
345 ret=res.GetTReal(trg);
349 return((TReal64)res);
352 EXPORT_C TReal32 __divsf3(TReal32 a1,TReal32 a2)
363 TInt ret=x1.Div(res,x2);
364 if (ret==KErrNone) // must check this because if underflow, error is lost in conversion
365 ret=res.GetTReal(trg);
369 return((TReal32)res);
372 EXPORT_C TReal64 __divdf3(TReal64 a1,TReal64 a2)
374 // Divide two doubles
383 TInt ret=x1.Div(res,x2);
384 if (ret==KErrNone) // must check this because if underflow, error is lost in conversion
385 ret=res.GetTReal(trg);
389 return((TReal64)res);
392 EXPORT_C TReal32 __negsf2(TReal32 a1)
399 return((TReal32)-x1);
402 EXPORT_C TReal64 __negdf2(TReal64 a1)
409 return((TReal64)-x1);
412 EXPORT_C TReal32 __floatsisf(TInt a1)
414 // Convert int to float
418 return((TReal32)TRealX(a1));
421 EXPORT_C TReal64 __floatsidf(TInt a1)
423 // Convert int to double
427 return((TReal64)TRealX(a1));
430 EXPORT_C TInt __fixsfsi(TReal32 a1)
432 // Convert float to int
436 return((TInt)TRealX(a1));
439 EXPORT_C TInt __fixdfsi(TReal64 a1)
441 // Convert double to int
445 return((TInt)TRealX(a1));
448 EXPORT_C TReal64 __extendsfdf2(TReal32 a1)
450 // Convert a float to a double
454 return((TReal64)TRealX(a1));
457 EXPORT_C TReal32 __truncdfsf2(TReal64 a1)
459 // Convert a double to a float
460 // Raises an exception if conversion results in an error
468 if ((ret=x1.GetTReal(trg))!=KErrNone)
473 #endif //__REALS_MACHINE_CODED__