sl@0
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32\euser\maths\um_spec.cpp
|
sl@0
|
15 |
// Functions to check for and set special values
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
#include "um_std.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
|
sl@0
|
23 |
|
sl@0
|
24 |
|
sl@0
|
25 |
#ifndef __REALS_MACHINE_CODED__
|
sl@0
|
26 |
EXPORT_C TBool Math::IsZero(const TReal &aVal)
|
sl@0
|
27 |
/**
|
sl@0
|
28 |
Determines whether a value is zero.
|
sl@0
|
29 |
|
sl@0
|
30 |
@param aVal A reference to the value to be checked.
|
sl@0
|
31 |
|
sl@0
|
32 |
@return True, if aVal is zero; false, otherwise.
|
sl@0
|
33 |
*/
|
sl@0
|
34 |
{
|
sl@0
|
35 |
|
sl@0
|
36 |
SReal64 *pS=(SReal64 *)&aVal;
|
sl@0
|
37 |
|
sl@0
|
38 |
if (pS->msm==0 && pS->lsm==0 && pS->exp==KTReal64ZeroExponent)
|
sl@0
|
39 |
return TRUE;
|
sl@0
|
40 |
else
|
sl@0
|
41 |
return FALSE;
|
sl@0
|
42 |
}
|
sl@0
|
43 |
|
sl@0
|
44 |
|
sl@0
|
45 |
|
sl@0
|
46 |
|
sl@0
|
47 |
EXPORT_C TBool Math::IsNaN(const TReal &aVal)
|
sl@0
|
48 |
/**
|
sl@0
|
49 |
Determines whether a value is not a number.
|
sl@0
|
50 |
|
sl@0
|
51 |
@param aVal A reference to the value to be checked.
|
sl@0
|
52 |
|
sl@0
|
53 |
@return True, if aVal is not a number; false, otherwise.
|
sl@0
|
54 |
*/
|
sl@0
|
55 |
{
|
sl@0
|
56 |
|
sl@0
|
57 |
SReal64 *pS=(SReal64 *)&aVal;
|
sl@0
|
58 |
|
sl@0
|
59 |
if (pS->exp==KTReal64SpecialExponent && (pS->msm|pS->lsm)!=0)
|
sl@0
|
60 |
return TRUE;
|
sl@0
|
61 |
else
|
sl@0
|
62 |
return FALSE;
|
sl@0
|
63 |
}
|
sl@0
|
64 |
|
sl@0
|
65 |
|
sl@0
|
66 |
|
sl@0
|
67 |
|
sl@0
|
68 |
EXPORT_C TBool Math::IsInfinite(const TReal &aVal)
|
sl@0
|
69 |
/**
|
sl@0
|
70 |
Determines whether a value is infinite.
|
sl@0
|
71 |
|
sl@0
|
72 |
@param aVal A reference to the value to be checked.
|
sl@0
|
73 |
|
sl@0
|
74 |
@return True, if aVal is infinite; false, otherwise.
|
sl@0
|
75 |
*/
|
sl@0
|
76 |
{
|
sl@0
|
77 |
|
sl@0
|
78 |
SReal64 *pS=(SReal64 *)&aVal;
|
sl@0
|
79 |
|
sl@0
|
80 |
if (pS->msm==0 && pS->lsm==0 && pS->exp==KTReal64SpecialExponent)
|
sl@0
|
81 |
return TRUE;
|
sl@0
|
82 |
else
|
sl@0
|
83 |
return FALSE;
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
|
sl@0
|
87 |
|
sl@0
|
88 |
|
sl@0
|
89 |
EXPORT_C TBool Math::IsFinite(const TReal &aVal)
|
sl@0
|
90 |
/**
|
sl@0
|
91 |
Determines whether a value is finite.
|
sl@0
|
92 |
|
sl@0
|
93 |
In this context, a value is finite if it is a valid number and
|
sl@0
|
94 |
is not infinite.
|
sl@0
|
95 |
|
sl@0
|
96 |
@param aVal A reference to the value to be checked.
|
sl@0
|
97 |
|
sl@0
|
98 |
@return True, if aVal is finite; false, otherwise.
|
sl@0
|
99 |
*/
|
sl@0
|
100 |
{
|
sl@0
|
101 |
|
sl@0
|
102 |
SReal64 *pS=(SReal64 *)&aVal;
|
sl@0
|
103 |
|
sl@0
|
104 |
if (pS->exp!=KTReal64SpecialExponent)
|
sl@0
|
105 |
return TRUE;
|
sl@0
|
106 |
else
|
sl@0
|
107 |
return FALSE;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
|
sl@0
|
111 |
|
sl@0
|
112 |
|
sl@0
|
113 |
EXPORT_C void Math::SetZero(TReal &aVal,TInt aSign)
|
sl@0
|
114 |
//
|
sl@0
|
115 |
// Constructs zeros, assuming default sign is positive
|
sl@0
|
116 |
//
|
sl@0
|
117 |
{
|
sl@0
|
118 |
|
sl@0
|
119 |
SReal64 *pS=(SReal64 *)&aVal;
|
sl@0
|
120 |
pS->sign=aSign;
|
sl@0
|
121 |
pS->exp=KTReal64ZeroExponent;
|
sl@0
|
122 |
pS->msm=0;
|
sl@0
|
123 |
pS->lsm=0;
|
sl@0
|
124 |
}
|
sl@0
|
125 |
|
sl@0
|
126 |
|
sl@0
|
127 |
|
sl@0
|
128 |
|
sl@0
|
129 |
EXPORT_C void Math::SetNaN(TReal &aVal)
|
sl@0
|
130 |
//
|
sl@0
|
131 |
// Constructs NaN (+ve sign for Java)
|
sl@0
|
132 |
//
|
sl@0
|
133 |
{
|
sl@0
|
134 |
|
sl@0
|
135 |
SReal64 *pS=(SReal64 *)&aVal;
|
sl@0
|
136 |
pS->sign=0;
|
sl@0
|
137 |
pS->exp=KTReal64SpecialExponent;
|
sl@0
|
138 |
pS->msm=0xfffffu;
|
sl@0
|
139 |
pS->lsm=0xffffffffu;
|
sl@0
|
140 |
}
|
sl@0
|
141 |
|
sl@0
|
142 |
|
sl@0
|
143 |
|
sl@0
|
144 |
|
sl@0
|
145 |
EXPORT_C void Math::SetInfinite(TReal &aVal,TInt aSign)
|
sl@0
|
146 |
//
|
sl@0
|
147 |
// Constructs infinities
|
sl@0
|
148 |
//
|
sl@0
|
149 |
{
|
sl@0
|
150 |
|
sl@0
|
151 |
SReal64 *pS=(SReal64 *)&aVal;
|
sl@0
|
152 |
pS->sign=aSign;
|
sl@0
|
153 |
pS->exp=KTReal64SpecialExponent;
|
sl@0
|
154 |
pS->msm=0;
|
sl@0
|
155 |
pS->lsm=0;
|
sl@0
|
156 |
}
|
sl@0
|
157 |
#endif
|
sl@0
|
158 |
|