0
|
1 |
// Copyright (c) 1997-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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32\euser\epoc\arm\uc_realx.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include "u32std.h"
|
|
19 |
#include <e32math.h>
|
|
20 |
|
|
21 |
GLDEF_C void PanicOverUnderflowDividebyZero(const TInt aErr)
|
|
22 |
//
|
|
23 |
// Panics if there is an overflow or underflow or divide by zero
|
|
24 |
//
|
|
25 |
{
|
|
26 |
// if (aErr==KErrOverflow)
|
|
27 |
// Panic(EMathOverflow);
|
|
28 |
// if (aErr==KErrUnderflow)
|
|
29 |
// Panic(EMathUnderflow);
|
|
30 |
// if (aErr==KErrDivideByZero)
|
|
31 |
// Panic(EMathDivideByZero);
|
|
32 |
// if (aErr==KErrArgument)
|
|
33 |
// Panic(EMathBadOperand);
|
|
34 |
User::Panic(_L("MATHX"),aErr);
|
|
35 |
}
|
|
36 |
|
|
37 |
#ifdef __REALS_MACHINE_CODED__
|
|
38 |
extern "C" void __math_exception(TInt aErrType)
|
|
39 |
//
|
|
40 |
// Decides on type of maths exception according to error and raises exception.
|
|
41 |
// Added by AnnW, December 1996
|
|
42 |
//
|
|
43 |
{
|
|
44 |
|
|
45 |
TExcType excType=EExcGeneral;
|
|
46 |
|
|
47 |
switch (aErrType)
|
|
48 |
{
|
|
49 |
case KErrArgument: // error due to invalid operation
|
|
50 |
excType=EExcFloatInvalidOperation;
|
|
51 |
break;
|
|
52 |
case KErrDivideByZero:
|
|
53 |
excType=EExcFloatDivideByZero;
|
|
54 |
break;
|
|
55 |
case KErrOverflow:
|
|
56 |
excType=EExcFloatOverflow;
|
|
57 |
break;
|
|
58 |
case KErrUnderflow:
|
|
59 |
excType=EExcFloatUnderflow;
|
|
60 |
break;
|
|
61 |
/*
|
|
62 |
// also errors due to inexact result
|
|
63 |
case KErrInexact: // const not defined yet
|
|
64 |
excType=EExcFloatInexact;
|
|
65 |
break;
|
|
66 |
*/
|
|
67 |
|
|
68 |
default:
|
|
69 |
// Unknown error
|
|
70 |
// Panic(EMathUnknownError);
|
|
71 |
User::Panic(_L("MATHX"),KErrGeneral);
|
|
72 |
}
|
|
73 |
|
|
74 |
User::RaiseException(excType);
|
|
75 |
}
|
|
76 |
#endif
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
#ifdef __EABI_CTORS__
|
|
82 |
EXPORT_C TRealX::TRealX()
|
|
83 |
/**
|
|
84 |
Constructs a default extended precision object.
|
|
85 |
|
|
86 |
This sets the value to zero.
|
|
87 |
*/
|
|
88 |
{
|
|
89 |
// Be Brutal (this should be as efficient as the naked versions)
|
|
90 |
TUint * me = (TUint *)this;
|
|
91 |
me[0]=me[1]=me[2]=0;
|
|
92 |
}
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
EXPORT_C TRealX::TRealX(TUint anExp, TUint aMantHi, TUint aMantLo)
|
|
98 |
/**
|
|
99 |
Constructs an extended precision object from an explicit exponent and
|
|
100 |
a 64 bit mantissa.
|
|
101 |
|
|
102 |
@param anExp The exponent
|
|
103 |
@param aMantHi The high order 32 bits of the 64 bit mantissa
|
|
104 |
@param aMantLo The low order 32 bits of the 64 bit mantissa
|
|
105 |
*/
|
|
106 |
{
|
|
107 |
// Be Brutal (this should be as efficient as the naked versions)
|
|
108 |
TUint * me = (TUint *)this;
|
|
109 |
me[0]=aMantLo;
|
|
110 |
me[1]=aMantHi;
|
|
111 |
me[2]=anExp;
|
|
112 |
}
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
EXPORT_C TRealX::TRealX(TInt anInt)
|
|
118 |
/**
|
|
119 |
Constructs an extended precision object from a signed integer value.
|
|
120 |
|
|
121 |
@param anInt The signed integer value.
|
|
122 |
*/
|
|
123 |
{
|
|
124 |
TRealX::operator=(anInt);
|
|
125 |
}
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
EXPORT_C TRealX::TRealX(const TInt64& anInt)
|
|
131 |
/**
|
|
132 |
Constructs an extended precision object from a 64 bit integer.
|
|
133 |
|
|
134 |
@param anInt A reference to a 64 bit integer.
|
|
135 |
*/
|
|
136 |
{
|
|
137 |
TRealX::operator=(anInt);
|
|
138 |
}
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
EXPORT_C TRealX::TRealX(TUint anInt)
|
|
144 |
/**
|
|
145 |
Constructs an extended precision object from an unsigned integer value.
|
|
146 |
|
|
147 |
@param anInt The unsigned integer value.
|
|
148 |
*/
|
|
149 |
{
|
|
150 |
TRealX::operator=(anInt);
|
|
151 |
}
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
EXPORT_C TRealX::TRealX(TReal32 aReal)__SOFTFP
|
|
157 |
/**
|
|
158 |
Constructs an extended precision object from
|
|
159 |
a single precision floating point number.
|
|
160 |
|
|
161 |
@param aReal The single precision floating point value.
|
|
162 |
*/
|
|
163 |
{
|
|
164 |
TRealX::operator=(aReal);
|
|
165 |
}
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
|
170 |
EXPORT_C TRealX::TRealX(TReal64 aReal)__SOFTFP
|
|
171 |
/**
|
|
172 |
Constructs an extended precision object from
|
|
173 |
a double precision floating point number.
|
|
174 |
|
|
175 |
@param aReal The double precision floating point value.
|
|
176 |
*/
|
|
177 |
{
|
|
178 |
TRealX::operator=(aReal);
|
|
179 |
}
|
|
180 |
#endif
|