os/kernelhwsrv/kerneltest/e32test/math/t_math.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/math/t_math.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,2943 @@
     1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test\math\t_math.cpp
    1.18 +// T_MATH.CPP - Test routines for the maths functions
    1.19 +// NB When considering the accuracy of the results (i.e. the tolerance used in testApprox()) it
    1.20 +// should be remembered that the results expected are not always given to full precision and so
    1.21 +// the results obtained are mostly as accurate as can be expected.
    1.22 +// Overview:
    1.23 +// Test functionality of the Math library.
    1.24 +// API Information:
    1.25 +// Math.
    1.26 +// Details:
    1.27 +// - Test math's trigonometric, powers, roots, logs, modulo, sqrt, exp,
    1.28 +// Int, Frac, rounding for range of input values are as expected.
    1.29 +// - Test the returned error values are as expected when illegal math's
    1.30 +// operations are done.
    1.31 +// - Check the return value is KErrTotalLossOfPrecision when incorrect values
    1.32 +// is passed to modulo function.
    1.33 +// - Test for success when the same variable for both operands in some 
    1.34 +// Math functions are used.
    1.35 +// Platforms/Drives/Compatibility:
    1.36 +// All.
    1.37 +// Assumptions/Requirement/Pre-requisites:
    1.38 +// Failures and causes:
    1.39 +// Base Port information:
    1.40 +// 
    1.41 +//
    1.42 +
    1.43 +#include "t_math.h"
    1.44 +#include "t_vals.h"
    1.45 +
    1.46 +LOCAL_D RTest test(_L("T_MATH"));
    1.47 +
    1.48 +LOCAL_D TInt64 rseed = MAKE_TINT64(123456789,987654321);
    1.49 +
    1.50 +typedef struct
    1.51 +    {
    1.52 +    TReal num; // input number
    1.53 +    TReal res; // expected result
    1.54 +    } SQRT_TEST;
    1.55 +
    1.56 +LOCAL_D SQRT_TEST testsqrt[]=
    1.57 +    {
    1.58 +    {0.0,0.0}, // zero
    1.59 +	{KNegZeroTReal64,KNegZeroTReal64},
    1.60 +    {1.0,1.0},
    1.61 +    {.64,.8},
    1.62 +    {.81,.9},
    1.63 +    {9,3},
    1.64 +    {25,5},
    1.65 +    {10000,100},
    1.66 +    {400,20},
    1.67 +    {6.25,2.5},
    1.68 +    {1E-98,1E-49},
    1.69 +    {1E-98,1E-49},
    1.70 +    {1E98,1E49},
    1.71 +    {1.0000000001,1.00000000005}
    1.72 +    };
    1.73 +
    1.74 +typedef struct
    1.75 +    {
    1.76 +    TReal num; // input number
    1.77 +    TReal res; // expected result
    1.78 +    } TESTLN;
    1.79 +
    1.80 +LOCAL_D TESTLN testln[]=
    1.81 +    {
    1.82 +    {.001,-6.9077552789821317},
    1.83 +    {.002,-6.2146080984221917},
    1.84 +    {.023,-3.7722610630529874},
    1.85 +    {.004,-5.5214609178622464},
    1.86 +    {.050,-2.9957322735539910},
    1.87 +    {.100,-2.3025850929940457},
    1.88 +    {.150,-1.8971199848858813},
    1.89 +    {.200,-1.6094379124341004},
    1.90 +    {.250,-1.3862943611198906},
    1.91 +    {.300,-1.2039728043259360},
    1.92 +    {.350,-1.0498221244986777},
    1.93 +    {.400,-0.9162907318741551},
    1.94 +    {.450,-0.7985076962177716},
    1.95 +    {.500,-0.6931471805599453},
    1.96 +    {.550,-0.5978370007556204},
    1.97 +    {.600,-0.5108256237659907},
    1.98 +    {.650,-0.4307829160924543},
    1.99 +    {.700,-0.3566749439387324},
   1.100 +    {.750,-0.2876820724517809},
   1.101 +    {.980,-0.0202027073175194},
   1.102 +    {.985,-0.0151136378100482},
   1.103 +    {.990,-0.0100503358535014},
   1.104 +    {.995,-0.0050125418235443},
   1.105 +    {.088,-2.4304184645039306},
   1.106 +    {1,0}
   1.107 +    };
   1.108 +
   1.109 +typedef struct
   1.110 +    {
   1.111 +    TReal val; // value for which the exponent is to be found
   1.112 +    TReal result; // result
   1.113 +    } EXP;
   1.114 +
   1.115 +LOCAL_D EXP testexp[]=
   1.116 +    {
   1.117 +    {4E-20,1.0}, 
   1.118 +	{5.4E-20,1.0},
   1.119 +	{0.0,1.0},
   1.120 +	{5E-324,1.0},
   1.121 +    };
   1.122 +
   1.123 +typedef struct
   1.124 +    {
   1.125 +    TReal number; // number to be raised to a power
   1.126 +    TReal power; // power
   1.127 +    TReal result; // result
   1.128 +    } POWER;
   1.129 +
   1.130 +LOCAL_D POWER testpow[]=
   1.131 +    {
   1.132 +	{45,3,91125.0},
   1.133 +	{-2,4,16},
   1.134 +    {2,-3,0.125},
   1.135 +    {-2,3,-8},
   1.136 +    {16,20,1.208925819614628E+24},
   1.137 +    };
   1.138 +
   1.139 +// Added by AnnW, October 1996
   1.140 +LOCAL_D const POWER testpowexact[]=
   1.141 +	{
   1.142 +	{0.0,1.0,0.0},
   1.143 +	{0,7,0},
   1.144 +	{0.0,16.0,0.0},
   1.145 +	{0.0,3.9271E-17,0.0},
   1.146 +	{-2,0,1},
   1.147 +    {1,0,1},
   1.148 +	{1.545243,0,1},
   1.149 +	{4.8,0.0,1.0},
   1.150 +	{195.0,0.0,1.0},
   1.151 +	{1.0E-7,0.0,1.0},
   1.152 +	{1.0,2.0,1.0},
   1.153 +	{1.0,1.0E-6,1.0},
   1.154 +	{1.0,1.0E+10,1.0},
   1.155 +	{-1.0,2.0,1.0},
   1.156 +	{-1.0,1.0000000001E+10,-1.0},
   1.157 +	{-1.0,1.0E+10,1.0},
   1.158 +	{1.593704102953967e+3,1.0,1.593704102953967e+3},
   1.159 +	{1.234567E+50,1.0,1.234567E+50},
   1.160 +	{1.2345678901234567E+146,1.0,1.2345678901234567E+146},
   1.161 +	{-7.6543210987654321E-53,1.0,-7.6543210987654321E-53},
   1.162 +	{0.0,2.0,0.0},
   1.163 +	{KNegZeroTReal64,4.0,0.0},
   1.164 +	{KPosInfTReal64,-2.0,0.0},
   1.165 +	{KNegInfTReal64,-2.0,0.0},
   1.166 +	{2.0,KNegInfTReal64,0.0},
   1.167 +	{-2.0,KNegInfTReal64,0.0},
   1.168 +	{0.5,KPosInfTReal64,0.0},
   1.169 +	{-0.5,KPosInfTReal64,0.0},
   1.170 +	{KPosInfTReal64,-5.0,0.0},
   1.171 +	{KPosInfTReal64,-6.0,0.0},
   1.172 +	{KNegInfTReal64,KNegInfTReal64,0.0},
   1.173 +	{KPosInfTReal64,KNegInfTReal64,0.0},
   1.174 +	};
   1.175 +
   1.176 +// Check ISO requirements on Pow()
   1.177 +//
   1.178 +typedef struct
   1.179 +	{
   1.180 +	TReal number;	// number to be raised to a power
   1.181 +	TReal power;	// power
   1.182 +	TInt rc;		// return value from Pow()
   1.183 +	TReal result;	// numerical result
   1.184 +	} POWERISO;
   1.185 +
   1.186 +const TReal KPosZeroTReal64 = 0.0;
   1.187 +
   1.188 +LOCAL_D const POWERISO testpow_iso[] =
   1.189 +	{
   1.190 +	// pow(+/-0, y) returns +/-INF and raises the ''divide-by-zero''
   1.191 +	// floating-point exception for y an odd integer < 0
   1.192 +	{ KPosZeroTReal64, -3.0, KErrOverflow, KPosInfTReal64 },	// 0
   1.193 +	{ KNegZeroTReal64, -3.0, KErrOverflow, KNegInfTReal64 },	// 1
   1.194 +
   1.195 +	// pow(+/-0, y) returns +INF and raises the ''divide-by-zero''
   1.196 +	// floating-point exception for y < 0 and not an odd integer
   1.197 +	{ KPosZeroTReal64, -2.0, KErrOverflow, KPosInfTReal64 },	// 2
   1.198 +	{ KNegZeroTReal64, -2.0, KErrOverflow, KPosInfTReal64 },	// 3
   1.199 +
   1.200 +	// pow(+/-0, y) returns +/-0 for y an odd integer > 0
   1.201 +	{ KPosZeroTReal64, 3.0, KErrNone, KPosZeroTReal64 },		// 4
   1.202 +	{ KNegZeroTReal64, 3.0, KErrNone, KNegZeroTReal64 },		// 5
   1.203 +
   1.204 +	// pow(+/-0, y) returns +0 for y > 0 and not an odd integer
   1.205 +	{ KPosZeroTReal64, 2.0, KErrNone, KPosZeroTReal64 },		// 6
   1.206 +	{ KNegZeroTReal64, 2.0, KErrNone, KPosZeroTReal64 },		// 7
   1.207 +
   1.208 +	// pow(-1, +/-INF) returns 1
   1.209 +	{ -1.0, KPosInfTReal64, KErrNone, 1.0 },					// 8
   1.210 +	{ -1.0, KNegInfTReal64, KErrNone, 1.0 },					// 9
   1.211 +
   1.212 +	// pow(+1, y) returns 1 for any y, even a NaN
   1.213 +	{ 1.0, 1.0, KErrNone, 1.0 },								// 10
   1.214 +	{ 1.0, 10.0, KErrNone, 1.0 },								// 11
   1.215 +	{ 1.0, -1.0, KErrNone, 1.0 },								// 12
   1.216 +	{ 1.0, -10.0, KErrNone, 1.0 },								// 13
   1.217 +	{ 1.0, 0.5, KErrNone, 1.0 },								// 14
   1.218 +	{ 1.0, -0.5, KErrNone, 1.0 },								// 15
   1.219 +	{ 1.0, KPosInfTReal64, KErrNone, 1.0 },						// 16
   1.220 +	{ 1.0, KNegInfTReal64, KErrNone, 1.0 },						// 17
   1.221 +	{ 1.0, KNaNTReal64, KErrNone, 1.0 },						// 18
   1.222 +
   1.223 +	// pow(x, +/-0) returns 1 for any x, even a NaN
   1.224 +	{  1.0, KPosZeroTReal64, KErrNone, 1.0 },					// 19
   1.225 +	{  1.0, KNegZeroTReal64, KErrNone, 1.0 },					// 20
   1.226 +	{  2.0, KPosZeroTReal64, KErrNone, 1.0 },					// 21
   1.227 +	{  2.0, KNegZeroTReal64, KErrNone, 1.0 },					// 22
   1.228 +	{  0.5, KPosZeroTReal64, KErrNone, 1.0 },					// 23
   1.229 +	{  0.5, KNegZeroTReal64, KErrNone, 1.0 },					// 24
   1.230 +	{ -1.0, KPosZeroTReal64, KErrNone, 1.0 },					// 25
   1.231 +	{ -1.0, KNegZeroTReal64, KErrNone, 1.0 },					// 26
   1.232 +	{ -2.0, KPosZeroTReal64, KErrNone, 1.0 },					// 27
   1.233 +	{ -2.0, KNegZeroTReal64, KErrNone, 1.0 },					// 28
   1.234 +	{ -0.5, KPosZeroTReal64, KErrNone, 1.0 },					// 29
   1.235 +	{ -0.5, KNegZeroTReal64, KErrNone, 1.0 },					// 30
   1.236 +	{ KPosZeroTReal64, KPosZeroTReal64, KErrNone, 1.0 },		// 31
   1.237 +	{ KPosZeroTReal64, KNegZeroTReal64, KErrNone, 1.0 },		// 32
   1.238 +	{ KNegZeroTReal64, KPosZeroTReal64, KErrNone, 1.0 },		// 33
   1.239 +	{ KNegZeroTReal64, KNegZeroTReal64, KErrNone, 1.0 },		// 34
   1.240 +	{ KPosInfTReal64, KPosZeroTReal64, KErrNone, 1.0 },			// 35
   1.241 +	{ KPosInfTReal64, KNegZeroTReal64, KErrNone, 1.0 },			// 36
   1.242 +	{ KNegInfTReal64, KPosZeroTReal64, KErrNone, 1.0 },			// 37
   1.243 +	{ KNegInfTReal64, KNegZeroTReal64, KErrNone, 1.0 },			// 38
   1.244 +	{ KNaNTReal64, KPosZeroTReal64, KErrNone, 1.0 },			// 39
   1.245 +	{ KNaNTReal64, KNegZeroTReal64, KErrNone, 1.0 },			// 40
   1.246 +
   1.247 +	// pow(x, y) returns a NaN and raises the ''invalid'' floating-point
   1.248 +	// exception for finite x < 0 and finite non-integer y
   1.249 +	{ -1.0, 1.5, KErrArgument, KNaNTReal64 },					// 41
   1.250 +
   1.251 +	// pow(x, -INF) returns +INF for |x| < 1
   1.252 +	{ 0.5, KNegInfTReal64, KErrOverflow, KPosInfTReal64 },		// 42
   1.253 +	{ -0.5, KNegInfTReal64, KErrOverflow, KPosInfTReal64 },		// 43
   1.254 +
   1.255 +	// pow(x, -INF) returns +0 for |x| > 1
   1.256 +	{ 2, KNegInfTReal64, KErrNone, KPosZeroTReal64 },			// 44
   1.257 +	{ -2, KNegInfTReal64, KErrNone, KPosZeroTReal64 },			// 45
   1.258 +	{ 4.5, KNegInfTReal64, KErrNone, KPosZeroTReal64 },			// 46
   1.259 +	{ -4.5, KNegInfTReal64, KErrNone, KPosZeroTReal64 },		// 47
   1.260 +
   1.261 +	// pow(x, +INF) returns +0 for |x| < 1
   1.262 +	{ .5, KPosInfTReal64, KErrNone, KPosZeroTReal64 },			// 48
   1.263 +	{ -.5, KPosInfTReal64, KErrNone, KPosZeroTReal64 },			// 49
   1.264 +
   1.265 +	// pow(x, +INF) returns +INF for |x| > 1
   1.266 +	{ 2, KPosInfTReal64, KErrOverflow, KPosInfTReal64 },		// 50
   1.267 +	{ -2, KPosInfTReal64, KErrOverflow, KPosInfTReal64 },		// 51
   1.268 +	{ 4.5, KPosInfTReal64, KErrOverflow, KPosInfTReal64 },		// 52
   1.269 +	{ -4.5, KPosInfTReal64, KErrOverflow, KPosInfTReal64 },		// 53
   1.270 +
   1.271 +	// pow(-INF, y) returns -0 for y an odd integer < 0
   1.272 +	{ KNegInfTReal64, -1, KErrNone, KNegZeroTReal64 },			// 54
   1.273 +	{ KNegInfTReal64, -5, KErrNone, KNegZeroTReal64 },			// 55
   1.274 +
   1.275 +	// pow(-INF, y) returns +0 for y < 0 and not an odd integer
   1.276 +	{ KNegInfTReal64, -2, KErrNone, KPosZeroTReal64 },			// 56
   1.277 +	{ KNegInfTReal64, -5.5, KErrNone, KPosZeroTReal64 },		// 57
   1.278 +
   1.279 +	// pow(-INF, y) returns -INF for y an odd integer > 0
   1.280 +	{ KNegInfTReal64, 1, KErrOverflow, KNegInfTReal64 },		// 58
   1.281 +	{ KNegInfTReal64, 5, KErrOverflow, KNegInfTReal64 },		// 59
   1.282 +
   1.283 +	// pow(-INF, y) returns +INF for y > 0 and not an odd integer
   1.284 +	{ KNegInfTReal64, 2, KErrOverflow, KPosInfTReal64 },		// 60
   1.285 +	{ KNegInfTReal64, 5.5, KErrOverflow, KPosInfTReal64 },		// 61
   1.286 +
   1.287 +	// pow(+INF, y) returns +0 for y < 0
   1.288 +	{ KPosInfTReal64, -1, KErrNone, KPosZeroTReal64 },			// 62
   1.289 +	{ KPosInfTReal64, -2, KErrNone, KPosZeroTReal64 },			// 63
   1.290 +	{ KPosInfTReal64, -5, KErrNone, KPosZeroTReal64 },			// 64
   1.291 +	{ KPosInfTReal64, -5.5, KErrNone, KPosZeroTReal64 },		// 65
   1.292 +
   1.293 +	// pow(+INF, y) returns +INF for y > 0
   1.294 +	{ KPosInfTReal64, 1, KErrOverflow, KPosInfTReal64 },		// 66
   1.295 +	{ KPosInfTReal64, 2, KErrOverflow, KPosInfTReal64 },		// 67
   1.296 +	{ KPosInfTReal64, 5, KErrOverflow, KPosInfTReal64 },		// 68
   1.297 +	{ KPosInfTReal64, 5.5, KErrOverflow, KPosInfTReal64 },		// 69
   1.298 +	};
   1.299 +
   1.300 +struct POW10_TEST
   1.301 +    {
   1.302 +    TInt num; // input number
   1.303 +    TReal res; // expected result
   1.304 +    };
   1.305 +
   1.306 +LOCAL_D POW10_TEST pow10teste[]=
   1.307 +	{
   1.308 +	{300,1.0E300},		
   1.309 +	{-162,1.0E-162},
   1.310 +	{-300,1.0E-300},
   1.311 +	{-99,1.0E-99},
   1.312 +//	};
   1.313 +
   1.314 +//LOCAL_D POW10_TEST pow10testa[]=
   1.315 +//	{
   1.316 +	{99,1.0E99},
   1.317 +	{283,1.0E283},
   1.318 +	{-89,1.0E-89},
   1.319 +	{-200,1.0E-200},
   1.320 +	{-43,1.0E-43},
   1.321 +	{24,1.0E24},
   1.322 + 	{-310,K1EMinus310Real64},
   1.323 + 	{-323,K1EMinus323Real64}
   1.324 +	};
   1.325 +
   1.326 +typedef struct
   1.327 +    {
   1.328 +    TReal num; // input number
   1.329 +    TReal res; // expected result
   1.330 +    } TESTSINE;
   1.331 +
   1.332 +#pragma warning ( disable : 4204 ) // non-constant aggregate initializer
   1.333 +LOCAL_D TESTSINE testsin[]=
   1.334 +    {
   1.335 +	{0.5,0.4794255386042029},						// These were found using S3a
   1.336 +	{1.2,0.9320390859672263},
   1.337 +	{1.6,0.9995736030415051},
   1.338 +	{28.6,-0.3199399618841981},
   1.339 +	{-18.3,0.5223085896267315},
   1.340 +	{KPi/4,0.7071067811865474},
   1.341 +	{3*KPi/4,0.7071067811865474},
   1.342 +	{5*KPi/4,-0.7071067811865474},
   1.343 +	{-KPi/4,-0.7071067811865474},
   1.344 +	{KPi/3,0.8660254037844387},
   1.345 +	{-KPi/3,-0.8660254037844387},
   1.346 +	{KPi/6,0.5},
   1.347 +	{-KPi/6,-0.5},
   1.348 +	{150*KDegToRad,0.5},
   1.349 +	{210*KDegToRad,-0.5},
   1.350 +//	{KPi+1.0E-15,-7.657143961860984E-16},	// loss of significance will limit accuracy here
   1.351 +//	2*(KPi+1.0E-15),1.5314287923721969e-15}
   1.352 +    };
   1.353 +    
   1.354 +typedef struct
   1.355 +    {
   1.356 +    TReal num; // input number
   1.357 +    TReal res; // expected result
   1.358 +    } TESTCOSINE;
   1.359 +
   1.360 +LOCAL_D TESTCOSINE testcos[]=
   1.361 +	{
   1.362 +	{0.5,0.8775825618903727},			// These were found using S3a
   1.363 +	{1.2,0.3623577544766734},
   1.364 +	{1.6,-0.0291995223012888},
   1.365 +	{28.6,-0.9474378189567576},
   1.366 +	{-18.3,0.8527565521308730},
   1.367 +	{KPi/4,0.7071067811865474},
   1.368 +	{3*KPi/4,-0.7071067811865474},
   1.369 +	{5*KPi/4,-0.7071067811865474},
   1.370 +	{-KPi/4,0.7071067811865474},
   1.371 +	{KPi/6,0.8660254037844387},
   1.372 +	{5*KPi/6,-0.8660254037844387},
   1.373 +	{KPi/3,0.5},
   1.374 +	{4*KPi/3,-0.5},
   1.375 +	{120*KDegToRad,-0.5},
   1.376 +	{300*KDegToRad,0.5},
   1.377 +	{KPi+1.0E-15,-1.0},
   1.378 +	{2*(KPi+1.0E-15),1.0}
   1.379 +	};
   1.380 +
   1.381 +typedef struct
   1.382 +    {
   1.383 +    TReal angle; // angle for which the tangent is to be found
   1.384 +    TReal result; // result
   1.385 +    } TAN;
   1.386 +
   1.387 +LOCAL_D TAN testtan[]=
   1.388 +    {
   1.389 +	{KPi/4,1.0},
   1.390 +	{-KPi/4,-1.0},
   1.391 +	{45*KDegToRad,1.0},
   1.392 +	{KPi/3,1.732050807568877},					// Added by AnnW - Calculated on S3a
   1.393 +	{2*KPi/3,-1.732050807568878},				//
   1.394 +	{KPi/6,0.5773502691896257},					//
   1.395 +	{-KPi/6,-0.5773502691896257},				//
   1.396 +	{89*KDegToRad,57.28996163075913},			// these two should be the same!
   1.397 +	{91*KDegToRad,-57.28996163075955},			//
   1.398 +    {4E-123,4E-123},								
   1.399 +    {-4E-123,-4E-123},	
   1.400 +    };
   1.401 +    
   1.402 +typedef struct
   1.403 +    {
   1.404 +    TReal num; // input number
   1.405 +    TReal res; // expected result
   1.406 +    } TESTASC;
   1.407 +
   1.408 +LOCAL_D TESTASC testas[]=
   1.409 +    {
   1.410 +    {.75,.848062078981},
   1.411 +    {.82,.961411018764},
   1.412 +    {.87,1.055202320549},
   1.413 +    {.89,1.097345169523},
   1.414 +    {.90,1.119769514999},
   1.415 +    {.92,1.168080485214},
   1.416 +    {.94,1.222630305522},
   1.417 +    {.96,1.287002217587},
   1.418 +    {.99,1.429256853470},
   1.419 +    {1.0,1.570796326795},
   1.420 +	{0.0,0},
   1.421 +	{-1.0, -90.0*KDegToRad},
   1.422 +	{0.5,30.0*KDegToRad}
   1.423 +    };
   1.424 +
   1.425 +typedef struct
   1.426 +    {
   1.427 +    TReal num1; // Divisor
   1.428 +    TReal num2; // Divand
   1.429 +    TReal res; // expected result
   1.430 +    } TESTATAN2;
   1.431 +
   1.432 +LOCAL_D TESTATAN2 testat2[]=
   1.433 +    {
   1.434 +    {5E-49,7E306,0.0}, // underflow, zero returned
   1.435 +    {5E49,7E-306,KPiBy2}, // overflow, pi/2 returned
   1.436 +    {0.45,0.5,0.732815101787},
   1.437 +    {0.12,0.3,0.380506377112},
   1.438 +    {0.3,0.0,KPiBy2}, // overflow, pi/2 returned
   1.439 +    {-0.3,0.0,-KPiBy2}, // overflow, -pi/2 returned
   1.440 +    {0.0,0.3,0.0},
   1.441 +    };
   1.442 +#pragma warning ( default : 4204 )
   1.443 +
   1.444 +typedef struct
   1.445 +    {
   1.446 +    TReal num; // input number
   1.447 +    TReal res; // expected result
   1.448 +    } INT_TEST;
   1.449 +
   1.450 +LOCAL_D INT_TEST testint1[]=
   1.451 +    {
   1.452 +    {1.0,1.0},
   1.453 +    {1.47934,1.0},
   1.454 +    {-72.86345,-72.0},
   1.455 +    {-734.9999,-734.0},
   1.456 +    {4855.9974,4855.0},
   1.457 +    {232478.35,232478.0},
   1.458 +    {0.029345,0.0},
   1.459 +    {0.9437,0.0},
   1.460 +    {-0.2634,0.0},
   1.461 +    {-0.98976,0.0},
   1.462 +    {32769.36946,32769.0},
   1.463 +    {-32774.997937,-32774.0},
   1.464 +    {8738465.38749,8738465.0},
   1.465 +    {-2348645.34965,-2348645.0},
   1.466 +    {2147483655.7565,2147483655.0},
   1.467 +    {-2147483657.89453,-2147483657.0},
   1.468 +    {2374843546.34E2,2374843546.34E2},
   1.469 +    {34780656.37643E12,34780656.37643E12},
   1.470 +    {-2374843546.34E2,-2374843546.34E2},
   1.471 +    {-34780656.37643E12,-34780656.37643E12},
   1.472 +    {468650.3874E47,468650.3874E47},
   1.473 +    {-4965.5987636E34,-4965.5987636E34},
   1.474 +    };
   1.475 +
   1.476 +typedef struct
   1.477 +    {
   1.478 +    TReal num; // input number
   1.479 +    TInt16 res; // expected result
   1.480 +    } INTI_TEST;
   1.481 +
   1.482 +LOCAL_D INTI_TEST testint2[]=
   1.483 +    {
   1.484 +    {1.0,1},
   1.485 +    {1.47934,1},
   1.486 +    {-72.86345,-72},
   1.487 +    {-734.9999,-734},
   1.488 +    {4855.9974,4855},
   1.489 +    {0.029345,0},
   1.490 +    {0.9437,0},
   1.491 +    {-0.2634,0},
   1.492 +    {-0.98976,0},
   1.493 +    {3234.56,3234},
   1.494 +    {4698.435,4698},
   1.495 +    {-32767.47658,-32767},
   1.496 +    {32767.9830857,32767},
   1.497 +    {-32768.47658,-32767-1}
   1.498 +    };
   1.499 +
   1.500 +typedef struct
   1.501 +    {
   1.502 +    TReal num; // input number
   1.503 +    TInt32 res; // expected result
   1.504 +    } INTL_TEST;
   1.505 +
   1.506 +LOCAL_D INTL_TEST testint3[]=
   1.507 +    {
   1.508 +    {1.0,1l},
   1.509 +    {1.47934,1l},
   1.510 +    {-72.86345,-72l},
   1.511 +    {-734.9999,-734l},
   1.512 +    {4855.9974,4855l},
   1.513 +    {0.029345,0l},
   1.514 +    {0.9437,0l},
   1.515 +    {-0.2634,0l},
   1.516 +    {-0.98976,0l},
   1.517 +    {3234.56,3234l},
   1.518 +    {4698.435,4698l},
   1.519 +    {-32767.47658,-32767l},
   1.520 +    {32767.9830857,32767l},
   1.521 +    {32769.36946,32769l},
   1.522 +    {-32774.997937,-32774l},
   1.523 +    {64835903.74605,64835903l},
   1.524 +    {-46652024.393,-46652024l},
   1.525 +    {2147483647.34576,2147483647l},
   1.526 +    {-2147483647.9501,-2147483647l},
   1.527 +    {-2147483648.00,0x80000000l}, 
   1.528 +    {-2147483648.6843,0x80000000l}
   1.529 +    };
   1.530 +
   1.531 +typedef struct
   1.532 +    {
   1.533 +    TReal num; // input number
   1.534 +    TReal res; // expected result
   1.535 +    } FRAC_TEST;
   1.536 +
   1.537 +LOCAL_D FRAC_TEST testfrac[]=
   1.538 +    {
   1.539 +	{0.0,0.0},
   1.540 +	{KNegZeroTReal64,0.0},
   1.541 +    {1.0,0.0},
   1.542 +    {1.47934,.47934},
   1.543 +    {-72.86345,-.86345},
   1.544 +    {-734.9999,-.9999},
   1.545 +    {4855.9974,.9974},
   1.546 +    {232478.35,.35},
   1.547 +    {0.029345,.029345},
   1.548 +    {0.9437,0.9437},
   1.549 +    {-0.2634,-.2634},
   1.550 +    {-0.98976,-.98976},
   1.551 +    {32769.36946,.36946},
   1.552 +    {-32774.997937,-0.997937},
   1.553 +    {8738465.38749,0.38749},
   1.554 +    {-2348645.34965,-0.34965},
   1.555 +    {2147483655.7565,0.7565},
   1.556 +    {-2147483657.89453,-.89453},
   1.557 +    {2374843546.34E2,0.0},
   1.558 +    {34780656.37643E12,0.0},
   1.559 +    {-2374843546.34E2,0.0},
   1.560 +    {-34780656.37643E12,0.0},
   1.561 +    {468650.3874E47,0.0},
   1.562 +    {-4965.5987636E34,0.0}
   1.563 +    };
   1.564 +
   1.565 +typedef struct
   1.566 +    {
   1.567 +    TReal num; // input number
   1.568 +    TReal mod; // modulo
   1.569 +    TReal res; // expected result
   1.570 +    } MOD_TEST;
   1.571 +
   1.572 +LOCAL_D MOD_TEST testmod[]=
   1.573 +    {
   1.574 +    {4.0,2.0,0.0},
   1.575 +    {3.0,2.0,1.0},
   1.576 +    {56.847,2.3,1.647},
   1.577 +    {-65.6478,.65,-.6478},
   1.578 +    {-6858.78432,-87.5323,-31.26492},
   1.579 +    {7665.140215,-34.98,4.520215},
   1.580 +    {.4645,1.0,0.4645},
   1.581 +    {-.246,1.0,-.246},
   1.582 +	{1.0,KPosInfTReal64,1.0},
   1.583 +	{1.0,KNegInfTReal64,1.0},
   1.584 +	{1.0E17,8.0,0.0},
   1.585 +	//
   1.586 +	{1.0,3.0,1.0},				//0
   1.587 +	{2.0,3.0,2.0},
   1.588 +	{4.0,3.0,1.0},
   1.589 +	{8.0,3.0,2.0},
   1.590 +	{16.0,3.0,1.0},
   1.591 +	{32.0,3.0,2.0},
   1.592 +	{64.0,3.0,1.0},
   1.593 +	{128.0,3.0,2.0},
   1.594 +	{256.0,3.0,1.0},
   1.595 +	{512.0,3.0,2.0},
   1.596 +	{1024.0,3.0,1.0},			//10
   1.597 +	{2048.0,3.0,2.0},
   1.598 +	{4096.0,3.0,1.0},
   1.599 +	{8192.0,3.0,2.0},
   1.600 +	{16384.0,3.0,1.0},
   1.601 +	{32768.0,3.0,2.0},
   1.602 +	{65536.0,3.0,1.0},
   1.603 +	{131072.0,3.0,2.0},
   1.604 +	{262144.0,3.0,1.0},
   1.605 +	{524288.0,3.0,2.0},
   1.606 +	{1048576.0,3.0,1.0},		//20
   1.607 +	{2097152.0,3.0,2.0},
   1.608 +	{4194304.0,3.0,1.0},
   1.609 +	{8388608.0,3.0,2.0},
   1.610 +	{16777216.0,3.0,1.0},
   1.611 +	{33554432.0,3.0,2.0},
   1.612 +	{67108864.0,3.0,1.0},
   1.613 +	{134217728.0,3.0,2.0},
   1.614 +	{268435456.0,3.0,1.0},
   1.615 +	{536870912.0,3.0,2.0},
   1.616 +	{1073741824.0,3.0,1.0},		//30
   1.617 +	{2147483648.0,3.0,2.0},
   1.618 +	{4294967296.0,3.0,1.0},
   1.619 +	{8589934592.0,3.0,2.0},
   1.620 +	{17179869184.0,3.0,1.0},
   1.621 +	{34359738368.0,3.0,2.0},
   1.622 +	{68719476736.0,3.0,1.0},
   1.623 +	{137438953472.0,3.0,2.0},
   1.624 +	{274877906944.0,3.0,1.0},
   1.625 +	{549755813888.0,3.0,2.0},
   1.626 +	{1099511627776.0,3.0,1.0},	//40
   1.627 +	{2199023255552.0,3.0,2.0},
   1.628 +	{4398046511104.0,3.0,1.0},
   1.629 +	{8796093022208.0,3.0,2.0},
   1.630 +	{17592186044416.0,3.0,1.0},
   1.631 +	{35184372088832.0,3.0,2.0},
   1.632 +	{70368744177664.0,3.0,1.0},
   1.633 +	{140737488355328.0,3.0,2.0},
   1.634 +	{281474976710656.0,3.0,1.0},
   1.635 +	{562949953421312.0,3.0,2.0},
   1.636 +	{1125899906842624.0,3.0,1.0},	//50
   1.637 +	{2251799813685248.0,3.0,2.0},
   1.638 +	{4503599627370496.0,3.0,1.0},
   1.639 +	{9007199254740992.0,3.0,2.0},
   1.640 +	{18014398509481984.0,3.0,1.0},
   1.641 +	{6.626176E-34,299792458.0,6.626176E-34},
   1.642 +	{-1.6022E-19,6.022045E23,-1.6022E-19},
   1.643 +	{0.0,2.71828182845904524,0.0}
   1.644 +    };
   1.645 +
   1.646 +// expected result is unused in following - will be zero in all cases
   1.647 +LOCAL_D MOD_TEST testmod2[]=
   1.648 +    {
   1.649 +	{1.0E17,7.9,0.0},
   1.650 +	{1.0E100,4.0,0.0},
   1.651 +	{KMaxTReal64,5.0,0.0},
   1.652 +	{-KMaxTReal64,5.0,0.0},
   1.653 +	{0.125,1.0E-17,0.0},
   1.654 +	{36028797019963968.0,2.0,0.0},   // 2**55,2**1
   1.655 +	//
   1.656 +	{36028797019963968.0,3.0,0.0},	//55
   1.657 +	{72057594039927936.0,3.0,0.0},
   1.658 +	{144115188079855872.0,3.0,0.0},
   1.659 +	{288230376159711744.0,3.0,0.0},
   1.660 +	};
   1.661 +
   1.662 +TInt testApprox(TReal aFound,TReal aExpect,TReal aTol)
   1.663 +//
   1.664 +// Tests relative error, i.e. whether (aFound-aExpect)/aFound <= aTol
   1.665 +//
   1.666 +	{
   1.667 +
   1.668 +	TRealX diff,check,l,r,t;
   1.669 +	l.Set(aFound);
   1.670 +	r.Set(aExpect);
   1.671 +	t.Set(aTol);
   1.672 +	if (l.Mult(check,t)==KErrUnderflow)
   1.673 +		{
   1.674 +		l*=TRealX(1.0E20);
   1.675 +		r*=TRealX(1.0E20);
   1.676 +		}
   1.677 +	diff=l-r;
   1.678 +	if (diff.IsZero())
   1.679 +		return ETrue;
   1.680 +	if (!l.IsZero())
   1.681 +		diff.DivEq(l);
   1.682 +	if (Abs(TReal(diff))<=aTol)
   1.683 +		return ETrue;
   1.684 +	return EFalse;
   1.685 +	}
   1.686 +
   1.687 +LOCAL_C void randrng(TReal& pret,TReal& llim,TReal& ulim)
   1.688 +/*
   1.689 +Returns a random number in the range [llim,ulim]
   1.690 +*/
   1.691 +    {
   1.692 +
   1.693 +    pret=Math::FRand(rseed);
   1.694 +    pret*=ulim-llim;
   1.695 +    pret+=llim;
   1.696 +    }
   1.697 +
   1.698 +LOCAL_C TReal taylor(TReal x,TInt k)
   1.699 +/*
   1.700 +Evaluate the Taylor series approximation to arc sine up to terms of order k
   1.701 +*/
   1.702 +    //TReal x; // argument
   1.703 +    //TInt k; // Highest order term
   1.704 +    {
   1.705 +
   1.706 +    TInt i,j;
   1.707 +    TReal den,num,res,term,di;
   1.708 +
   1.709 +    den=1;
   1.710 +    num=1;
   1.711 +    term=0;
   1.712 +    for (i=1;i<=k;i+=2)
   1.713 +		{
   1.714 +		for (j=2;j<i;j+=2)
   1.715 +			{
   1.716 +			num*=j;
   1.717 +			if (j<(i-1))
   1.718 +			den*=j+1;
   1.719 +			}
   1.720 +		di=(TReal)i;
   1.721 +		Math::Pow(res,x,di);
   1.722 +		term+=(res*den)/(i*num);
   1.723 +		num=1;
   1.724 +		den=1;
   1.725 +		}
   1.726 +    return(term);
   1.727 +    }
   1.728 +
   1.729 +LOCAL_C TReal tayatan(TReal val)
   1.730 +/* 
   1.731 +Finds the taylor series approximation to the arc tangent function 
   1.732 +*/
   1.733 +    //TReal val;
   1.734 +    {
   1.735 +
   1.736 +    TInt i;
   1.737 +    TReal sgn,s,d,di,term,res;
   1.738 +    
   1.739 +    term=0.0;
   1.740 +    s=(-1.0);
   1.741 +    for (i=0;i<8;i++)
   1.742 +		{
   1.743 +		di=(TReal)i;
   1.744 +		d=2.0*di;
   1.745 +		Math::Pow(sgn,s,di);
   1.746 +		Math::Pow(res,val,d);
   1.747 +		term+=(sgn*res)/(2.0*di+1.0);
   1.748 +		}
   1.749 +    return(val*term);
   1.750 +    }
   1.751 +
   1.752 +LOCAL_C void AssortedTests()
   1.753 +//
   1.754 +// Tests the methods with just a handful of values each 
   1.755 +// All tests as accurate as possible - if exact answer given, tests for equality
   1.756 +//
   1.757 +	{
   1.758 +
   1.759 +	TReal trg,src;
   1.760 +
   1.761 +	// ASin
   1.762 +	test.Start(_L("Math::ASin()"));
   1.763 +	test(Math::ASin(trg,0.0)==KErrNone);
   1.764 +	test(trg==0.0);
   1.765 +
   1.766 +	test(Math::ASin(trg,1.0)==KErrNone);
   1.767 +	test(testApprox(trg,1.5707963267949,5.0E-15));
   1.768 +
   1.769 +	// ACos
   1.770 +	test.Next(_L("Math::ACos()"));
   1.771 +	test(Math::ACos(trg,0)==KErrNone);
   1.772 +	test(testApprox(trg,1.5707963267949,5.0E-15));
   1.773 +
   1.774 +	test(Math::ACos(trg,1.0)==KErrNone);
   1.775 +	test(trg==0.0);
   1.776 +
   1.777 +	// ATan
   1.778 +	test.Next(_L("Math::ATan()"));
   1.779 +	test(Math::ATan(trg,0.0)==KErrNone);
   1.780 +	test(trg==0.0);
   1.781 +
   1.782 +	test(Math::ATan(trg,1.0)==KErrNone);
   1.783 +	test(testApprox(trg,0.78539816339745,5.0E-15));	
   1.784 +
   1.785 +	test(Math::Tan(trg,KPi/4)==KErrNone);
   1.786 +	test(testApprox(trg,1.0,1.0E-15));
   1.787 +	test(Math::ATan(trg,trg)==KErrNone);
   1.788 +	test(testApprox(trg,KPi/4,1e-15));
   1.789 +
   1.790 +	// Sqrt
   1.791 +	test.Next(_L("Math::Sqrt()"));
   1.792 +	test(Math::Sqrt(trg,0.0)==KErrNone);
   1.793 +	test(trg==0.0);
   1.794 +	
   1.795 +	test(Math::Sqrt(trg,-1.0)==KErrArgument);
   1.796 +
   1.797 +	test(Math::Sqrt(trg,100.0)==KErrNone);
   1.798 +	test(testApprox(trg,10.0,1.0E-15));	
   1.799 +
   1.800 +	test(Math::Sqrt(trg,56.25)==KErrNone);
   1.801 +	test(trg==7.5);
   1.802 +
   1.803 +	// Pow10
   1.804 +	test.Next(_L("Math::Pow10()"));
   1.805 +	test(Math::Pow10(trg,-2)==KErrNone);
   1.806 +	test(trg==0.01);	
   1.807 +
   1.808 +	test(Math::Pow10(trg,-1)==KErrNone);
   1.809 +	test(trg==0.1);
   1.810 +
   1.811 +	test(Math::Pow10(trg,0)==KErrNone);
   1.812 +	test(trg==1.0);
   1.813 +
   1.814 +	test(Math::Pow10(trg,1)==KErrNone);
   1.815 +	test(trg==10.0);
   1.816 +
   1.817 +	test(Math::Pow10(trg,2)==KErrNone);
   1.818 +	test(trg==100.0);
   1.819 +
   1.820 +	// Ln
   1.821 +	test.Next(_L("Math::Ln()"));
   1.822 +	test(Math::Ln(trg,0.0)==KErrOverflow);
   1.823 +	
   1.824 +	test(Math::Ln(trg,1.0)==KErrNone);
   1.825 +	test(trg==0.0);
   1.826 +
   1.827 +	test(Math::Ln(trg,2)==KErrNone);
   1.828 +	test(testApprox(trg,0.69314718055995,1.0E-14));	
   1.829 +
   1.830 +	// Log
   1.831 +	test.Next(_L("Math::Log()"));
   1.832 +	test(Math::Log(trg,0)==KErrOverflow);
   1.833 +
   1.834 +	test(Math::Log(trg,1)==KErrNone);
   1.835 +	test(trg==0);
   1.836 +
   1.837 +	test(Math::Log(trg,10)==KErrNone);
   1.838 +	test(trg==1);
   1.839 +
   1.840 +	test(Math::Log(trg,100000)==KErrNone);
   1.841 +	test(trg==5);
   1.842 +
   1.843 +	// Sin
   1.844 +	test.Next(_L("Math::Sin()"));
   1.845 +	test(Math::Sin(trg,0)==KErrNone);
   1.846 +	test(trg==0);   
   1.847 +
   1.848 +	test(Math::Sin(trg,1)==KErrNone);
   1.849 +	test(testApprox(trg,0.84147098480790,5.0E-15));	
   1.850 +
   1.851 +	test(Math::Sin(trg,KPi)==KErrNone);
   1.852 +//    test(trg==0.0);
   1.853 +	test(Abs(trg)<1e-15);
   1.854 +
   1.855 +	test(Math::Sin(trg,KPiBy2)==KErrNone);
   1.856 +	test(testApprox(trg,1.0,1.0E-15));
   1.857 +
   1.858 +	test(Math::Sin(trg,10.0*KPi)==KErrNone);
   1.859 +//   test(trg==0.0);
   1.860 +	test(Abs(trg)<2e-15);
   1.861 +
   1.862 +	test(Math::Sin(trg,3)==KErrNone);
   1.863 +	test(trg==0.1411200080598672);
   1.864 +
   1.865 +	test(Math::Sin(trg,4)==KErrNone);
   1.866 +	test(trg==-0.7568024953079282);
   1.867 +
   1.868 +	test(Math::Sin(trg,3.1415)==KErrNone);
   1.869 +	test(testApprox(trg,9.26535896605E-5,2.0E-13));	
   1.870 +
   1.871 +	test(Math::Sin(trg,3.1416)==KErrNone);
   1.872 +	test(testApprox(trg,-7.3464102066435914E-6,1.0E-11));	
   1.873 +
   1.874 +	test(Math::Sin(trg,(10.0*KPi)+0.001)==KErrNone);
   1.875 +	test(testApprox(trg,0.000999999833333,4.0E-13));	
   1.876 +
   1.877 +	// Cos
   1.878 +	test.Next(_L("Math::Cos()"));
   1.879 +	test(Math::Cos(trg,0.0)==KErrNone);
   1.880 +	test(testApprox(trg,1.0,1.0E-15));		
   1.881 +
   1.882 +	test(Math::Cos(trg,1)==KErrNone);
   1.883 +	test(testApprox(trg,0.54030230586814,1.0E-15));		
   1.884 +
   1.885 +    test(Math::Cos(trg,KPiBy2)==KErrNone);
   1.886 +//    test(trg==0.0);
   1.887 +	test(Abs(trg)<1e-15);
   1.888 +
   1.889 +	test(Math::Cos(trg,KPi)==KErrNone);
   1.890 +	test(trg==-1.0);
   1.891 +
   1.892 +    test(Math::Cos(trg,KPiBy2+KPi)==KErrNone);
   1.893 +//    test(trg==0.0);
   1.894 +	test(Abs(trg)<1e-15);
   1.895 +	
   1.896 +	test(Math::Cos(trg,89.99999*KDegToRad)==KErrNone);
   1.897 +	test(testApprox(trg,1.745329252E-07,5.0E-10));		
   1.898 +
   1.899 +	test(Math::Cos(trg,90.00001*KDegToRad)==KErrNone);
   1.900 +	test(testApprox(trg,-1.7453292516217e-007,5.0E-10));			
   1.901 +
   1.902 +	// Tan
   1.903 +	test.Next(_L("Math::Tan()"));
   1.904 +	test(Math::Tan(trg,0.0)==KErrNone);
   1.905 +    test(trg==0.0);   
   1.906 +
   1.907 +	test(Math::Tan(trg,1)==KErrNone);
   1.908 +	test(testApprox(trg,1.5574077246549,2.0E-15));			
   1.909 +
   1.910 +	// Pow
   1.911 +	test.Next(_L("Math::Pow()"));
   1.912 +	src=10;
   1.913 +	test(Math::Pow(trg,src,-1.0)==KErrNone);
   1.914 +	test(testApprox(trg,0.1,1.0E-15));			
   1.915 +
   1.916 +	test(Math::Pow(trg,src,0.0)==KErrNone);
   1.917 +	test(trg==1.0);
   1.918 +
   1.919 +	test(Math::Pow(trg,src,2.0)==KErrNone);
   1.920 +	test(testApprox(trg,100.0,1.0E-15));			
   1.921 +
   1.922 +	src=1.0;
   1.923 +	test(Math::Pow(trg,src,10000000000000000.0)==KErrNone);
   1.924 +	test(trg==1.0);
   1.925 +
   1.926 +	test.End();
   1.927 +	}       
   1.928 +
   1.929 +LOCAL_C void sqrtest1(TReal low,TReal upp)
   1.930 +/*
   1.931 +Test the identity sqrt(x*x)=x  on the range low<=x<upp
   1.932 +*/
   1.933 +    {
   1.934 +    
   1.935 +	TReal x,y,res;
   1.936 +
   1.937 +    for (TInt j=0;j<100;j++)
   1.938 +		{
   1.939 +		randrng(x,low,upp);
   1.940 +		y=x*x;
   1.941 +		test(Math::Sqrt(res,y)==KErrNone);
   1.942 +		test(testApprox(res,x,1.0E-15));
   1.943 +		}
   1.944 +    }
   1.945 +
   1.946 +LOCAL_C void sqrtest2()
   1.947 +/*
   1.948 +Tests specific numbers
   1.949 +*/
   1.950 +    {
   1.951 +    
   1.952 +	TReal root;
   1.953 +
   1.954 +	// test errors
   1.955 +	test(Math::Sqrt(root,KNaNTReal64)==KErrArgument);
   1.956 +	test(Math::IsNaN(root));
   1.957 +	test(Math::Sqrt(root,-1)==KErrArgument);
   1.958 +	test(Math::IsNaN(root));
   1.959 +	test(Math::Sqrt(root,KNegInfTReal64)==KErrArgument);
   1.960 +	test(Math::IsNaN(root));
   1.961 +	test(Math::Sqrt(root,KPosInfTReal64)==KErrOverflow);
   1.962 +	test(root==KPosInfTReal64);
   1.963 +
   1.964 +    TInt i=sizeof(testsqrt)/sizeof(SQRT_TEST);
   1.965 +    for (TInt j=0;j<i;j++) 
   1.966 +		{
   1.967 +		test(Math::Sqrt(root,testsqrt[j].num)==KErrNone);
   1.968 +		test(testApprox(root,testsqrt[j].res,1.0E-15));
   1.969 +		}
   1.970 +
   1.971 +	// a couple of denormal tests
   1.972 +	test(Math::Sqrt(root,4E-322)==KErrNone);
   1.973 +	test(testApprox(root,2E-161,1.0E-3));
   1.974 +	test(Math::Sqrt(root,1.6E-309)==KErrNone);
   1.975 +	test(testApprox(root,4E-155,1.0E-15));	
   1.976 +    }
   1.977 +
   1.978 +LOCAL_C void logtest()
   1.979 +/*
   1.980 +Test numbers in the range sqrt(.1) to .9, using the identity 
   1.981 +log(x)=log(11x/10)-log(1.1) 
   1.982 +*/
   1.983 +    {
   1.984 +
   1.985 +    TReal res,x;
   1.986 +    TReal cnstlog,cnstlogx;
   1.987 +
   1.988 +    TReal low=.316227766017;
   1.989 +    TReal upp=0.9;
   1.990 +    TReal cnst=11.0/10.0;
   1.991 +    test(Math::Log(cnstlog,cnst)==KErrNone);
   1.992 +    for (TInt j=0;j<10;j++)
   1.993 +		{
   1.994 +		randrng(x,low,upp);
   1.995 +		test(Math::Log(res,x)==KErrNone); 
   1.996 +		TReal num=cnst*x;
   1.997 +		test(Math::Log(cnstlogx,num)==KErrNone);
   1.998 +		test(testApprox(res,(cnstlogx-cnstlog),1.0E-15));
   1.999 +		}
  1.1000 +    }
  1.1001 +
  1.1002 +LOCAL_C void lntest1()
  1.1003 +/* 
  1.1004 +Test selected numbers 
  1.1005 +*/
  1.1006 +    {
  1.1007 + 
  1.1008 +    TReal res;
  1.1009 +
  1.1010 +	// test errors
  1.1011 +//	test(Math::Ln(res,KNegZeroTReal64)==KErrArgument);
  1.1012 +	test(Math::Ln(res,KNegZeroTReal64)==KErrOverflow);
  1.1013 +	test(Math::IsInfinite(res));
  1.1014 +	test(Math::Ln(res,-34)==KErrArgument);
  1.1015 +	test(Math::IsNaN(res));
  1.1016 +	test(Math::Ln(res,KNaNTReal64)==KErrArgument);
  1.1017 +	test(Math::IsNaN(res));
  1.1018 +	test(Math::Ln(res,KNegInfTReal64)==KErrArgument);
  1.1019 +	test(Math::IsNaN(res));
  1.1020 +	test(Math::Ln(res,KPosInfTReal64)==KErrOverflow);
  1.1021 +	test(res==KPosInfTReal64);
  1.1022 +	test(Math::Ln(res,0.0)==KErrOverflow);
  1.1023 +	test(res==KNegInfTReal64);
  1.1024 +	test(Math::Ln(res,2.71828182845904524)==KErrNone);
  1.1025 +	test(testApprox(res,1.0,1e-15));
  1.1026 +	test(Math::Ln(res,7.389056098930650227)==KErrNone);
  1.1027 +	test(testApprox(res,2.0,1e-15));
  1.1028 +
  1.1029 +    TInt i=sizeof(testln)/sizeof(TESTLN);
  1.1030 +    for (TInt j=0;j<i;j++) 
  1.1031 +		{
  1.1032 +		test(Math::Ln(res,testln[j].num)==KErrNone);
  1.1033 +		test(testApprox(res,testln[j].res,1.0E-14));
  1.1034 +		}
  1.1035 +
  1.1036 +	// test some denormals
  1.1037 + 	test(Math::Log(res,K1EMinus322Real64)==KErrNone);
  1.1038 +	test(testApprox(res,-322.0,2.0E-5));
  1.1039 + 	test(Math::Log(res,K1EMinus313Real64)==KErrNone);
  1.1040 +	test(testApprox(res,-313.0,1.0E-13));	
  1.1041 +    }
  1.1042 +
  1.1043 +LOCAL_C void lntest2()
  1.1044 +/* 
  1.1045 +Test numbers near to one against the Taylor series approximation 
  1.1046 +*/
  1.1047 +    {
  1.1048 +    
  1.1049 +	TReal x,res;
  1.1050 +    
  1.1051 +    TReal low=.999999989463;
  1.1052 +    TReal upp=1.00000001054;
  1.1053 +    for (TInt k=0;k<10;k++)
  1.1054 +		{
  1.1055 +		randrng(x,low,upp);
  1.1056 +		TRealX tot=0.0;
  1.1057 +		TRealX xx(x-1);
  1.1058 +		TInt sign=-1;
  1.1059 +		for (TInt i=4;i>0;i--)
  1.1060 +			{
  1.1061 +			tot+=TRealX(sign)/TRealX(i);
  1.1062 +			tot*=xx;
  1.1063 +			sign=-sign;
  1.1064 +			}
  1.1065 +		TReal tot2=(TReal)tot;
  1.1066 +		test(Math::Ln(res,x)==KErrNone);
  1.1067 +		test(testApprox(res,tot2,1.0E-15));
  1.1068 +		}
  1.1069 +    }
  1.1070 +
  1.1071 +LOCAL_C void lntest3()
  1.1072 +/* 
  1.1073 +Test numbers in the range sqrt(.5) to 15/16, using the identity 
  1.1074 +ln(x)=ln(17x/16)-ln(17/16) 
  1.1075 +*/
  1.1076 +    {
  1.1077 +
  1.1078 +    TReal x,cnstln,cnstlnx,res;
  1.1079 +
  1.1080 +	TReal low=KSqhf;
  1.1081 +    TReal upp=15.0/16.0;
  1.1082 +    TReal cnst=17.0/16.0;
  1.1083 +    test(Math::Ln(cnstln,cnst)==KErrNone);
  1.1084 +	for (TInt j=0;j<10;j++)
  1.1085 +		{
  1.1086 +		randrng(x,low,upp);
  1.1087 +		test(Math::Ln(res,x)==KErrNone);
  1.1088 +		TReal num=cnst*x;
  1.1089 +		test(Math::Ln(cnstlnx,num)==KErrNone);
  1.1090 +		test(testApprox(res,(cnstlnx-cnstln),1.0E-15));
  1.1091 +		}
  1.1092 +    }
  1.1093 +
  1.1094 +LOCAL_C void lntest4()
  1.1095 +/* 
  1.1096 +Test numbers in the range 16 to 240 using the identity ln(x*x)=2ln(x) 
  1.1097 +*/
  1.1098 +    {
  1.1099 +
  1.1100 +    TReal cnstlnx,res;
  1.1101 +
  1.1102 +    TReal low=16.0;
  1.1103 +    TReal upp=240.0;
  1.1104 +    TReal x=16.0;
  1.1105 +	test(Math::Ln(res,-1)==KErrArgument);
  1.1106 +    for (TInt j=0;j<10;j++)
  1.1107 +		{
  1.1108 +		randrng(x,low,upp);
  1.1109 +		TReal num=x*x;
  1.1110 +		test(Math::Ln(res,num)==KErrNone);
  1.1111 +		test(Math::Ln(cnstlnx,x)==KErrNone);
  1.1112 +		test(testApprox(res,2*cnstlnx,1.0E-15));
  1.1113 +		}
  1.1114 +    }
  1.1115 +
  1.1116 +LOCAL_C void exptest1()
  1.1117 +/* 
  1.1118 +To test exponent for specific values 
  1.1119 +*/
  1.1120 +    {
  1.1121 +
  1.1122 +    TReal res;
  1.1123 +
  1.1124 +	// test errors
  1.1125 +	test(Math::Exp(res,KNaNTReal64)==KErrArgument);
  1.1126 +	test(Math::IsNaN(res));
  1.1127 +	test(Math::Exp(res,KPosInfTReal64)==KErrOverflow);
  1.1128 +	test(res==KPosInfTReal64);
  1.1129 +	test(Math::Exp(res,709.8)==KErrOverflow);
  1.1130 +	test(res==KPosInfTReal64);
  1.1131 +	test(Math::Exp(res,KNegInfTReal64)==KErrUnderflow);
  1.1132 +	test(Math::IsZero(res));
  1.1133 +	test(Math::Exp(res,-745.2)==KErrUnderflow);
  1.1134 +	test(Math::IsZero(res));
  1.1135 +
  1.1136 +    TInt i=sizeof(testexp)/sizeof(EXP);
  1.1137 +    for (TInt j=0;j<i;j++)
  1.1138 +		{
  1.1139 +		test(Math::Exp(res,testexp[j].val)==KErrNone);
  1.1140 +		test(testApprox(res,testexp[j].result,0));	// NB only tests values with results of 1
  1.1141 +		}
  1.1142 +
  1.1143 +	// test some denormals
  1.1144 +	test(Math::Exp(res,5E-324)==KErrNone);
  1.1145 +	test(testApprox(res,1.0,0));
  1.1146 +	test(Math::Exp(res,-6E-318)==KErrNone);
  1.1147 +	test(testApprox(res,1.0,0));	
  1.1148 +	}
  1.1149 +
  1.1150 +LOCAL_C void exptest2(TReal cnst,TReal ll,TReal ul)
  1.1151 +/*
  1.1152 +Test the identity exp(x-cnst)=exp(x)*exp(-cnst) for x in the range [ul,ll]
  1.1153 +*/
  1.1154 +    //TReal cnst; // constant used in the identity
  1.1155 +    //TReal ll; // Lower limit of the range
  1.1156 +    //TReal ul; // Upper limit of the range
  1.1157 +    {
  1.1158 +
  1.1159 +    TReal cnstexp,cnstexpx,x,res;
  1.1160 +
  1.1161 +    test(Math::Exp(cnstexp,cnst)==KErrNone);
  1.1162 +    for (TInt j=0;j<10;j++)
  1.1163 +		{
  1.1164 +		randrng(x,ll,ul);
  1.1165 +		test(Math::Exp(res,x)==KErrNone);
  1.1166 +		TReal num=x+cnst;
  1.1167 +		test(Math::Exp(cnstexpx,num)==KErrNone);
  1.1168 +		test(testApprox(cnstexpx,(res*cnstexp),1.0E-15));
  1.1169 +		}
  1.1170 +    }
  1.1171 +
  1.1172 +LOCAL_C void exptest3()
  1.1173 +/* 
  1.1174 +Test for systematic error 
  1.1175 +*/
  1.1176 +    {
  1.1177 +    
  1.1178 +	TReal step,ul,v;
  1.1179 +
  1.1180 +    TReal x=1.0123;
  1.1181 +    TReal y=x/2;
  1.1182 +    test(Math::Exp(v,y)==KErrNone);
  1.1183 +    test(Math::Exp(step,x)==KErrNone);
  1.1184 +    test(Math::Sqrt(ul,step)==KErrNone);
  1.1185 +	test(testApprox(ul,v,1.0E-15));
  1.1186 +    }
  1.1187 +
  1.1188 +LOCAL_C void powtest1()
  1.1189 +/*
  1.1190 +Test selected numbers
  1.1191 +*/
  1.1192 +    {
  1.1193 +    
  1.1194 +	TReal res;
  1.1195 +	
  1.1196 +	// test errors
  1.1197 +	test(Math::Pow(res,10,-1E8)==KErrUnderflow);
  1.1198 +	test(res==0.0);
  1.1199 +	test(Math::Pow(res,10,-KMaxTReal64)==KErrUnderflow);
  1.1200 +	test(res==0.0);
  1.1201 +	test(Math::Pow(res,10,-5.5E307)==KErrUnderflow);
  1.1202 +	test(res==0.0);
  1.1203 +	test(Math::Pow(res,10,-5.4E307)==KErrUnderflow);
  1.1204 +	test(res==0.0);
  1.1205 +	test(Math::Pow(res,10,-1E300)==KErrUnderflow);
  1.1206 +	test(res==0.0);
  1.1207 +	test(Math::Pow(res,10,-1E10)==KErrUnderflow);
  1.1208 +	test(res==0.0);
  1.1209 +	
  1.1210 +	test(Math::Pow(res,10,5.5E307)==KErrOverflow);
  1.1211 +	test(res==KPosInfTReal64);
  1.1212 +	test(Math::Pow(res,10,5.4E307)==KErrOverflow);
  1.1213 +	test(res==KPosInfTReal64);
  1.1214 +	test(Math::Pow(res,10,1E308)==KErrOverflow);
  1.1215 +	test(res==KPosInfTReal64);
  1.1216 +	test(Math::Pow(res,10,1.7E308)==KErrOverflow);
  1.1217 +	test(res==KPosInfTReal64);
  1.1218 +	test(Math::Pow(res,10,KMaxTReal64)==KErrOverflow);
  1.1219 +	test(res==KPosInfTReal64);
  1.1220 +	
  1.1221 +	test(Math::Pow(res,1.0,KNaNTReal64)==KErrNone);
  1.1222 +	test(res==1.0);
  1.1223 +	test(Math::Pow(res,KNaNTReal64,1.0)==KErrArgument);
  1.1224 +	test(Math::IsNaN(res));
  1.1225 +	test(Math::Pow(res,0.0,KNaNTReal64)==KErrArgument);
  1.1226 +	test(Math::IsNaN(res));
  1.1227 +	test(Math::Pow(res,KNaNTReal64,0.0)==KErrNone);
  1.1228 +	test(res==1.0);
  1.1229 +	test(Math::Pow(res,KNaNTReal64,KNaNTReal64)==KErrArgument);
  1.1230 +	test(Math::IsNaN(res));
  1.1231 +	test(Math::Pow(res,KPosInfTReal64,KPosInfTReal64)==KErrOverflow);
  1.1232 +	test(res==KPosInfTReal64);
  1.1233 +//	test(Math::Pow(res,KNegInfTReal64,KPosInfTReal64)==KErrOverflow);
  1.1234 +//	test(res==KPosInfTReal64);
  1.1235 +	test(Math::Pow(res,KNegInfTReal64,KPosInfTReal64)==KErrOverflow);
  1.1236 +	test(res==KPosInfTReal64);
  1.1237 +	test(Math::Pow(res,2.0,KPosInfTReal64)==KErrOverflow);
  1.1238 +	test(res==KPosInfTReal64);
  1.1239 +//	test(Math::Pow(res,-2.0,KPosInfTReal64)==KErrOverflow);
  1.1240 +//	test(res==KPosInfTReal64);
  1.1241 +	test(Math::Pow(res,-2.0,KPosInfTReal64)==KErrOverflow);
  1.1242 +	test(res==KPosInfTReal64);
  1.1243 +	test(Math::Pow(res,0.5,KNegInfTReal64)==KErrOverflow);
  1.1244 +	test(res==KPosInfTReal64);
  1.1245 +//	test(Math::Pow(res,-0.5,KNegInfTReal64)==KErrOverflow);
  1.1246 +//	test(res==KPosInfTReal64);
  1.1247 +	test(Math::Pow(res,-0.5,KNegInfTReal64)==KErrOverflow);
  1.1248 +	test(res==KPosInfTReal64);
  1.1249 +//	test(Math::Pow(res,1.0,KPosInfTReal64)==KErrArgument);
  1.1250 +//	test(Math::IsNaN(res));
  1.1251 +	test(Math::Pow(res,1.0,KPosInfTReal64)==KErrNone);
  1.1252 +	test(res==1.0);
  1.1253 +	test(Math::Pow(res,-1.0,KPosInfTReal64)==KErrNone);
  1.1254 +	test(res==1.0);
  1.1255 +//	test(Math::Pow(res,1.0,KNegInfTReal64)==KErrArgument);
  1.1256 +//	test(Math::IsNaN(res));
  1.1257 +	test(Math::Pow(res,1.0,KNegInfTReal64)==KErrNone);
  1.1258 +	test(res==1.0);
  1.1259 +	test(Math::Pow(res,-1.0,KNegInfTReal64)==KErrNone);
  1.1260 +	test(res==1.0);
  1.1261 +	test(Math::Pow(res,0.0,0.0)==KErrNone);
  1.1262 +	test(res==1.0);
  1.1263 +	test(Math::Pow(res,KNegZeroTReal64,KNegZeroTReal64)==KErrNone);
  1.1264 +	test(res==1.0);
  1.1265 +	test(Math::Pow(res,0.0,KNegZeroTReal64)==KErrNone);
  1.1266 +	test(res==1.0);
  1.1267 +	test(Math::Pow(res,KNegZeroTReal64,0.0)==KErrNone);
  1.1268 +	test(res==1.0);
  1.1269 +	test(Math::Pow(res,KPosInfTReal64,2.0)==KErrOverflow);
  1.1270 +	test(res==KPosInfTReal64);
  1.1271 +	test(Math::Pow(res,0.0,-2.0)==KErrOverflow);
  1.1272 +	test(res==KPosInfTReal64);
  1.1273 +	test(Math::Pow(res,-2.0,-2.6)==KErrArgument);
  1.1274 +	test(Math::IsNaN(res));
  1.1275 +	test(Math::Pow(res,-2.0,4.8)==KErrArgument);
  1.1276 +	test(Math::IsNaN(res));
  1.1277 +	test(Math::Pow(res,KNegZeroTReal64,-5)==KErrOverflow);
  1.1278 +	test(res==KNegInfTReal64);
  1.1279 +	test(Math::Pow(res,KNegZeroTReal64,-6)==KErrOverflow);
  1.1280 +	test(res==KPosInfTReal64);
  1.1281 +	test(Math::Pow(res,30,999999)==KErrOverflow);	// checking bug fixed
  1.1282 +	test(res==KPosInfTReal64);
  1.1283 +	test(Math::Pow(res,200,200)==KErrOverflow);
  1.1284 +	test(res==KPosInfTReal64);
  1.1285 +	test(Math::Pow(res,200,2000)==KErrOverflow);	// checking bug fixed
  1.1286 +	test(res==KPosInfTReal64);
  1.1287 +	test(Math::Pow(res,1000,1000)==KErrOverflow);
  1.1288 +	test(res==KPosInfTReal64);
  1.1289 +	test(Math::Pow(res,1000,100)==KErrNone);
  1.1290 +	test(testApprox(res,1E+300,3.0E-15));
  1.1291 +	test(Math::Pow(res,1000,-1000)==KErrUnderflow);
  1.1292 +	test(Math::IsZero(res));
  1.1293 +	test(Math::Pow(res,1000,-100)==KErrNone);
  1.1294 +	test(testApprox(res,1E-300,4.0E-15));
  1.1295 +	
  1.1296 +	TInt j;
  1.1297 +    TInt i=sizeof(testpow)/sizeof(POWER);
  1.1298 +    for (j=0;j<i;j++)
  1.1299 +		{
  1.1300 +		test(Math::Pow(res,testpow[j].number,testpow[j].power)==KErrNone);
  1.1301 +		test(testApprox(res,testpow[j].result,1.0E-15));
  1.1302 +		}
  1.1303 +
  1.1304 +	// Added by AnnW, October 1996
  1.1305 +	TInt size = sizeof(testpowexact)/sizeof(POWER);
  1.1306 +	for (j=0; j<size; j++)
  1.1307 +		{
  1.1308 +		test(Math::Pow(res,testpowexact[j].number,testpowexact[j].power)==KErrNone);
  1.1309 +		test(res==testpowexact[j].result);
  1.1310 +		}
  1.1311 +
  1.1312 +	// denormals (base only - do not know results for denormal power)
  1.1313 + 	test(Math::Pow(res,K5EMinus324Real64,1.0)==KErrNone);
  1.1314 + 	test(res==K5EMinus324Real64);
  1.1315 + 	test(Math::Pow(res,K5EMinus324Real64,0.0)==KErrNone);
  1.1316 +	test(res==1.0);
  1.1317 +	test(Math::Pow(res,2E-160,2.0)==KErrNone);
  1.1318 +	test(testApprox(res,K4EMinus320Real64,1.0E-4));		
  1.1319 +
  1.1320 +	// This test is to check that reduce() is working properly
  1.1321 +	// This is only a very approximate test due to loss of significance for such nos
  1.1322 +	TReal base,power;
  1.1323 +	for (TReal powerOfTwo=16.0; powerOfTwo<=54.0; powerOfTwo++)
  1.1324 +		{
  1.1325 +		Math::Pow(power,2.0,powerOfTwo);
  1.1326 +		power+=0.7;
  1.1327 + 		Math::Pow(base,2.0,1/power);
  1.1328 +		test(Math::Pow(res,base,power)==KErrNone);
  1.1329 +		test((2.0-res)<=1.0);
  1.1330 +		}
  1.1331 +    }
  1.1332 +
  1.1333 +LOCAL_C void powtest2(TReal low,TReal upp)
  1.1334 +/*
  1.1335 +Test the identity (x**2)**1.5=x**3  on the range low<=x<upp
  1.1336 +*/
  1.1337 +    //TReal low; // lower limit of range to test
  1.1338 +    //TReal upp; // upper limit of range to test 
  1.1339 +    {
  1.1340 +    
  1.1341 +	TReal res,rres,x;
  1.1342 +
  1.1343 +	for (TInt j=0;j<10;j++)
  1.1344 +		{
  1.1345 +		randrng(x,low,upp);
  1.1346 +		TReal y=2;
  1.1347 +		test(Math::Pow(res,x,y)==KErrNone);
  1.1348 +		TReal xr=res;
  1.1349 +		y=1.5;
  1.1350 +		test(Math::Pow(res,xr,y)==KErrNone);
  1.1351 +		TReal yr=3;
  1.1352 +		test(Math::Pow(rres,x,yr)==KErrNone);    
  1.1353 +		test(testApprox(rres,res,1.0E-14));
  1.1354 +		}
  1.1355 +    }
  1.1356 +
  1.1357 +LOCAL_C void powtest3()
  1.1358 +/* 
  1.1359 +Test the identity x**1=x 
  1.1360 +*/
  1.1361 +    {
  1.1362 +    
  1.1363 +	TReal x,res;
  1.1364 + 
  1.1365 +    TReal low=.5;
  1.1366 +    TReal upp=1.0;
  1.1367 +    for (TInt j=0;j<10;j++)
  1.1368 +		{
  1.1369 +		randrng(x,low,upp);
  1.1370 +		TReal y=1.0;
  1.1371 +		test(Math::Pow(res,x,y)==KErrNone);
  1.1372 +		test(testApprox(res,x,1.0E-15));
  1.1373 +		}
  1.1374 +    }
  1.1375 +
  1.1376 +LOCAL_C void powtest4()
  1.1377 +/* 
  1.1378 +Test the identity (x**2)**(y/2)=x**y 
  1.1379 +*/
  1.1380 +    {
  1.1381 +    
  1.1382 +	TReal res,xr,rres,x,y;
  1.1383 +    
  1.1384 +    TReal low=.01;
  1.1385 +    TReal upp=10.0;
  1.1386 +    TReal lowy=-98; // range for y
  1.1387 +    TReal uppy=98;
  1.1388 +    for (TInt j=0;j<10;j++)
  1.1389 +		{
  1.1390 +		randrng(x,low,upp);
  1.1391 +		randrng(y,lowy,uppy);
  1.1392 +		test(Math::Pow(res,x,y)==KErrNone);
  1.1393 +		TReal yr=2;
  1.1394 +		test(Math::Pow(xr,x,yr)==KErrNone);
  1.1395 +		y/=2;
  1.1396 +		test(Math::Pow(rres,xr,y)==KErrNone);
  1.1397 +		test(testApprox(res,rres,5.0E-14));
  1.1398 +		}
  1.1399 +    }
  1.1400 +
  1.1401 +LOCAL_C void powtest5()
  1.1402 +/* 
  1.1403 +Test the identity x**y=1/(x**(-y)) 
  1.1404 +*/
  1.1405 +    {
  1.1406 +    
  1.1407 +	TReal x,y;
  1.1408 +    TReal res,rres;
  1.1409 +    
  1.1410 +	test(Math::Pow(res,-2,-3.765)==KErrArgument);
  1.1411 +    TReal low=0.5;
  1.1412 +    TReal upp=1.0;
  1.1413 +    for (TInt j=0;j<10;j++)
  1.1414 +		{
  1.1415 +		randrng(x,low,upp);
  1.1416 +		randrng(y,low,upp);
  1.1417 +		test(Math::Pow(res,x,y)==KErrNone);
  1.1418 +		y*=(-1);
  1.1419 +		test(Math::Pow(rres,x,y)==KErrNone);
  1.1420 +		rres=1/rres;
  1.1421 +		test(testApprox(res,rres,5.0E-15));
  1.1422 +		}
  1.1423 +    }
  1.1424 +
  1.1425 +LOCAL_C void powtest6()
  1.1426 +/* 
  1.1427 +Test specific ISO requirements on Pow()
  1.1428 +*/
  1.1429 +	{
  1.1430 +	TInt i;
  1.1431 +	TInt n = sizeof(testpow_iso) / sizeof(POWERISO);
  1.1432 +	for (i = 0; i < n; i++)
  1.1433 +		{
  1.1434 +		TReal ans;
  1.1435 +		TInt rc;
  1.1436 +
  1.1437 +		// If one of these tests fails, convert the "failed check xx" number
  1.1438 +		// to an index in testpow_iso[] by subtracting 1 and then dividing by 2.
  1.1439 +		// If the original number was odd, the first test (rc == xxx) failed.
  1.1440 +		// If the original number was even, the second test (.result) failed.
  1.1441 +		rc = Math::Pow(ans, testpow_iso[i].number, testpow_iso[i].power);
  1.1442 +		test(rc == testpow_iso[i].rc);
  1.1443 +		test((rc == KErrArgument) || (ans == testpow_iso[i].result));
  1.1444 +		}
  1.1445 +	}
  1.1446 +
  1.1447 +LOCAL_C void pow10test()
  1.1448 +//
  1.1449 +// Test Pow10() for various selected values - results should indicate which string to 
  1.1450 +// binary conversions would NOT be expected to be exact - see t_float
  1.1451 +//
  1.1452 +	{
  1.1453 +
  1.1454 +	TReal res;
  1.1455 +
  1.1456 +	// test errors
  1.1457 +	test(Math::Pow10(res,-324)==KErrUnderflow);
  1.1458 +	test(res==0.0);
  1.1459 +	test(Math::Pow10(res,-400)==KErrUnderflow);
  1.1460 +	test(res==0.0);
  1.1461 +	test(Math::Pow10(res,309)==KErrOverflow);
  1.1462 +	test(res==KPosInfTReal64);
  1.1463 +	test(Math::Pow10(res,400)==KErrOverflow);
  1.1464 +	test(res==KPosInfTReal64);
  1.1465 +
  1.1466 +	TInt j;
  1.1467 +	TInt i=sizeof(pow10teste)/sizeof(POW10_TEST);
  1.1468 +
  1.1469 +	for (j=0; j<i; j++)
  1.1470 +		{
  1.1471 +		test(Math::Pow10(res,pow10teste[j].num)==KErrNone);
  1.1472 +		test(res==pow10teste[j].res);
  1.1473 +		}
  1.1474 +
  1.1475 +/*	i=sizeof(pow10testa)/sizeof(POW10_TEST);
  1.1476 +	
  1.1477 +	for (j=0; j<i; j++)
  1.1478 +		{
  1.1479 +		test(Math::Pow10(res,pow10testa[j].num)==KErrNone);
  1.1480 +		test(testApprox(res,pow10testa[j].res,1.0E-15));
  1.1481 +		}
  1.1482 +*/	}
  1.1483 +
  1.1484 +LOCAL_C void sintest1(TReal low,TReal upp)
  1.1485 +/*
  1.1486 +Test the identity sin(x)=sin(x/3)[3-4*(sin(x/3))**2] on the range low<=x<upp
  1.1487 +*/
  1.1488 +    //TReal low; // lower limit of range to test
  1.1489 +    //TReal upp; // upper limit of range to test 
  1.1490 +    {
  1.1491 +    
  1.1492 +	TReal x,res,rres;
  1.1493 +
  1.1494 +    for (TInt j=0;j<100;j++)
  1.1495 +		{
  1.1496 +		randrng(x,low,upp);
  1.1497 +		test(Math::Sin(res,x)==KErrNone);
  1.1498 +		x/=3;
  1.1499 +		test(Math::Sin(rres,x)==KErrNone);
  1.1500 +		TReal err=rres*rres;
  1.1501 +		err*=4;
  1.1502 +		err=3-err;
  1.1503 +		err*=rres;
  1.1504 +		test(testApprox(res,err,1.0E-12));
  1.1505 +		}
  1.1506 +    }
  1.1507 +
  1.1508 +LOCAL_C void sintest2()
  1.1509 +/* 
  1.1510 +Test selected values (which may not give exact results) 
  1.1511 +*/
  1.1512 +    {
  1.1513 +    
  1.1514 +	TReal res;
  1.1515 +	
  1.1516 +	// test errors
  1.1517 +	test(Math::Sin(res,KNaNTReal64)==KErrArgument);
  1.1518 +	test(Math::IsNaN(res));
  1.1519 +	test(Math::Sin(res,KPosInfTReal64)==KErrArgument);
  1.1520 +	test(Math::IsNaN(res));
  1.1521 +	test(Math::Sin(res,KNegInfTReal64)==KErrArgument);
  1.1522 +	test(Math::IsNaN(res));
  1.1523 +	test(Math::Sin(res,2147483648.0*KPi)==KErrArgument);
  1.1524 +	test(Math::IsNaN(res));
  1.1525 +	test(Math::Sin(res,-1E+10)==KErrArgument);
  1.1526 +	test(Math::IsNaN(res));
  1.1527 +
  1.1528 +	TInt i=sizeof(testsin)/sizeof(TESTSINE);
  1.1529 +    TInt j;
  1.1530 +    
  1.1531 +	for (j=0;j<i;j++)
  1.1532 +		{
  1.1533 +		TReal x=testsin[j].num;
  1.1534 +		TReal y=testsin[j].res;
  1.1535 +		test(Math::Sin(res,x)==KErrNone);
  1.1536 +   		test(testApprox(res,y,1.0E-15));
  1.1537 +		}
  1.1538 +
  1.1539 +	//Added by AnnW, October 1996
  1.1540 +	TInt mult=101;
  1.1541 +	for (j=-(mult-1); j<mult; j++)
  1.1542 +		{
  1.1543 +		test(Math::Sin(res, (4*j+1)*KPiBy2)==KErrNone);
  1.1544 +		test(testApprox(res,1.0,1.0E-15));
  1.1545 +
  1.1546 +		test(Math::Sin(res, (4*j+3)*KPiBy2)==KErrNone);
  1.1547 +		test(testApprox(res,-1.0,1.0E-15));
  1.1548 +
  1.1549 +		test(Math::Sin(res, ((4*j+1)*90)*KDegToRad)==KErrNone);
  1.1550 +		test(testApprox(res,1.0,1.0E-15));
  1.1551 +
  1.1552 +		test(Math::Sin(res, ((4*j+3)*90)*KDegToRad)==KErrNone);
  1.1553 +		test(testApprox(res,-1.0,1.0E-15));
  1.1554 +		}
  1.1555 +	//
  1.1556 +    }
  1.1557 +
  1.1558 +LOCAL_C void sintest3()
  1.1559 +/* 
  1.1560 +To test the identity sin(-x)=-sin(x) on the range [0,10*pi] 
  1.1561 +*/        
  1.1562 +    {
  1.1563 +    
  1.1564 +	TReal x,res,rres;
  1.1565 +
  1.1566 +    TReal low=0.0;
  1.1567 +    TReal upp=10*KPi;
  1.1568 +    for (TInt j=0;j<10;j++)
  1.1569 +		{
  1.1570 +		randrng(x,low,upp);
  1.1571 +		test(Math::Sin(res,x)==KErrNone);
  1.1572 +		x*=(-1);
  1.1573 +		test(Math::Sin(rres,x)==KErrNone);
  1.1574 +		test(testApprox(rres,-res,1.0E-15));
  1.1575 +		}
  1.1576 +    }
  1.1577 +
  1.1578 +LOCAL_C void sintest4()
  1.1579 +/* 
  1.1580 +To test the identity sin(x)=x for x<<1 
  1.1581 +*/        
  1.1582 +    {
  1.1583 +    
  1.1584 +	TReal res,x;
  1.1585 +    TReal low=1E-90;
  1.1586 +    TReal upp=1E-10;
  1.1587 +
  1.1588 +    for (TInt j=0;j<10;j++)
  1.1589 +		{
  1.1590 +		randrng(x,low,upp);
  1.1591 +		test(Math::Sin(res,x)==KErrNone);
  1.1592 +		test(testApprox(res,x,1.0E-15));
  1.1593 +		}
  1.1594 +
  1.1595 +	// test some denormals
  1.1596 +	test(Math::Sin(res,5E-324)==KErrNone);
  1.1597 +	test(testApprox(res,5E-324,1.0E-15));
  1.1598 +	test(Math::Sin(res,7E-317)==KErrNone);
  1.1599 +	test(testApprox(res,7E-317,1.0E-15));		
  1.1600 +    }
  1.1601 +/*
  1.1602 +LOCAL_C void sintest5()
  1.1603 +//
  1.1604 +// To test that exact results are given for multiples of pi and
  1.1605 +// values sufficiently close to them 
  1.1606 +// Added by AnnW, October 1996
  1.1607 +//
  1.1608 +	{
  1.1609 +	
  1.1610 +	TReal res;
  1.1611 +	TInt j;
  1.1612 +	TInt mult=101; // can use up to 32768
  1.1613 +
  1.1614 +    test(Math::Sin(res,KNegZeroTReal64)==KErrNone);
  1.1615 +	test(res==0.0);
  1.1616 +
  1.1617 +    for (j=-(mult-1); j<mult; j++)
  1.1618 +		{
  1.1619 +		test(Math::Sin(res, j*KPi)==KErrNone);
  1.1620 +		test(res==0.0);
  1.1621 +		test(Math::Sin(res, j*(KPi+1.224E-16))==KErrNone);
  1.1622 +		test(res==0.0);
  1.1623 +		test(Math::Sin(res, (j*180)*KDegToRad)==KErrNone);
  1.1624 +		test(res==0.0);
  1.1625 +		if (j!=0)
  1.1626 +			{
  1.1627 +			test(Math::Sin(res, j*(KPi+1.0E-14))==KErrNone);
  1.1628 +			test(res!=0.0);
  1.1629 +			}		
  1.1630 +		}
  1.1631 +	}
  1.1632 +*/
  1.1633 +LOCAL_C void costest1()
  1.1634 +/* 
  1.1635 +To test the identity cos(x)=cos(x/3)[4*(cos(x/3)**2)-3] on the interval 
  1.1636 +[7*pi,7.5*pi] 
  1.1637 +Added by AnnW, October 1996
  1.1638 +*/
  1.1639 +    {
  1.1640 +
  1.1641 +    TReal x,res,rres;
  1.1642 +
  1.1643 +    TReal low=7*KPi;
  1.1644 +    TReal upp=7.5*KPi;
  1.1645 +    for (TInt j=0;j<100;j++)
  1.1646 +		{
  1.1647 +		randrng(x,low,upp);
  1.1648 +		test(Math::Cos(res,x)==KErrNone);
  1.1649 +		x/=3;
  1.1650 +		test(Math::Cos(rres,x)==KErrNone);
  1.1651 +		test(testApprox(res,rres*(4*(rres*rres)-3),5.0E-13));
  1.1652 +		}
  1.1653 +    }
  1.1654 +
  1.1655 +LOCAL_C void costest2()
  1.1656 +/*
  1.1657 +Test selected values (which may not give exact results) 
  1.1658 +Added by AnnW, October 1996
  1.1659 +*/
  1.1660 +    {
  1.1661 +    
  1.1662 +	TReal res;
  1.1663 +
  1.1664 +	// test errors
  1.1665 +	test(Math::Cos(res,KNaNTReal64)==KErrArgument);
  1.1666 +	test(Math::IsNaN(res));
  1.1667 +	test(Math::Cos(res,KPosInfTReal64)==KErrArgument);
  1.1668 +	test(Math::IsNaN(res));
  1.1669 +	test(Math::Cos(res,KNegInfTReal64)==KErrArgument);
  1.1670 +	test(Math::IsNaN(res));
  1.1671 +	test(Math::Cos(res,(2147483648.0*KPi))==KErrArgument);
  1.1672 +	test(Math::IsNaN(res));
  1.1673 +	test(Math::Sin(res,-1E+10)==KErrArgument);
  1.1674 +	test(Math::IsNaN(res));
  1.1675 +
  1.1676 +	TInt j;
  1.1677 +	TInt mult=101;
  1.1678 +	TInt i=sizeof(testcos)/sizeof(TESTCOSINE);
  1.1679 +
  1.1680 +    for (j=0; j<i; j++)
  1.1681 +		{
  1.1682 +		test(Math::Cos(res,testcos[j].num)==KErrNone);
  1.1683 +		test(testApprox(res,testcos[j].res,1.0E-15));		
  1.1684 +		}
  1.1685 +
  1.1686 +	test(Math::Cos(res,KNegZeroTReal64)==KErrNone);
  1.1687 +	test(testApprox(res,1.0,1E-15));
  1.1688 +
  1.1689 +    for (j=-(mult-1); j<mult; j++)
  1.1690 +		{
  1.1691 +		test(Math::Cos(res, (2*j)*KPi)==KErrNone);
  1.1692 +		test(testApprox(res,1.0,1.0E-15));		
  1.1693 +
  1.1694 +		test(Math::Cos(res, (2*j+1)*KPi)==KErrNone);
  1.1695 +		test(testApprox(res,-1.0,1.0E-15));		
  1.1696 +
  1.1697 +		test(Math::Cos(res, (2*j)*(KPi+1.224E-16))==KErrNone);
  1.1698 +		test(testApprox(res,1.0,1.0E-15));		
  1.1699 +
  1.1700 +		test(Math::Cos(res, (2*j+1)*(KPi+1.224E-16))==KErrNone);
  1.1701 +		test(testApprox(res,-1.0,1.0E-15));		
  1.1702 +
  1.1703 +		test(Math::Cos(res, ((2*j)*180)*KDegToRad)==KErrNone);
  1.1704 +		test(testApprox(res,1.0,1.0E-15));		
  1.1705 +
  1.1706 +		test(Math::Cos(res, ((2*j+1)*180)*KDegToRad)==KErrNone);
  1.1707 +		test(testApprox(res,-1.0,1.0E-15));		
  1.1708 +		}
  1.1709 +    }
  1.1710 +
  1.1711 +LOCAL_C void costest3()
  1.1712 +/* 
  1.1713 +To test the identity cos(-x)=cos(x) on the range [0,10*pi]
  1.1714 +Added by AnnW, October 1996 
  1.1715 +*/        
  1.1716 +    {
  1.1717 +
  1.1718 +    TReal x,res,rres;
  1.1719 +
  1.1720 +    TReal low=0.0;
  1.1721 +    TReal upp=10*KPi;
  1.1722 +    for (TInt j=0;j<10;j++)
  1.1723 +		{
  1.1724 +		randrng(x,low,upp);
  1.1725 +		test(Math::Cos(res,x)==KErrNone);
  1.1726 +		x*=(-1);
  1.1727 +		test(Math::Cos(rres,x)==KErrNone);
  1.1728 +		test(testApprox(rres,res,1.0E-15));		
  1.1729 +		}
  1.1730 +    }
  1.1731 +
  1.1732 +LOCAL_C void costest4()
  1.1733 +/* 
  1.1734 +To test the identity cos(x)=1 for x<<1 
  1.1735 +Added by Annw, October 1996
  1.1736 +*/        
  1.1737 +    {
  1.1738 +
  1.1739 +    TReal res,x;
  1.1740 +    TReal low=1E-90;
  1.1741 +    TReal upp=1E-10;
  1.1742 +
  1.1743 +    for (TInt j=0;j<10;j++)
  1.1744 +		{
  1.1745 +		randrng(x,low,upp);
  1.1746 +		test(Math::Cos(res,x)==KErrNone);
  1.1747 +		test(testApprox(res,1.0,1.0E-15));
  1.1748 +		}
  1.1749 +
  1.1750 +	// test some denormals
  1.1751 +	test(Math::Cos(res,5E-324)==KErrNone);
  1.1752 +	test(testApprox(res,1.0,1.0E-15));
  1.1753 +	test(Math::Cos(res,1.34E-315)==KErrNone);
  1.1754 +	test(testApprox(res,1.0,1.0E-15));			
  1.1755 +    }
  1.1756 +/*
  1.1757 +LOCAL_C void costest5()
  1.1758 +//
  1.1759 +// To test that exact results are given for multiples of KPi and
  1.1760 +// values sufficiently close to them 
  1.1761 +// Added by AnnW, October 1996
  1.1762 +//
  1.1763 +	{
  1.1764 +
  1.1765 +	TReal res;
  1.1766 +	TInt mult=101;	// can use up to 32768
  1.1767 +	TInt j;
  1.1768 +    
  1.1769 +    for (j=-(mult-1); j<mult; j++)
  1.1770 +		{
  1.1771 +		test(Math::Cos(res, (2*j+1)*KPiBy2)==KErrNone);
  1.1772 +		test(res==0.0);
  1.1773 +		test(Math::Cos(res, (2*j+1)*KPiBy2+(j+1)*1.224E-16)==KErrNone);
  1.1774 +		test(res==0.0);
  1.1775 +		test(Math::Cos(res, (2*j+1)*90*KDegToRad)==KErrNone);
  1.1776 +		test(res==0.0);
  1.1777 +		if (j!=0)
  1.1778 +			{
  1.1779 +			test(Math::Sin(res, (2*j+1)*(KPiBy2+1.0E-14))==KErrNone);
  1.1780 +			test(res!=0.0);
  1.1781 +			}
  1.1782 +		}
  1.1783 +	}
  1.1784 +*/
  1.1785 +LOCAL_C void tantest1(TReal low,TReal upp)
  1.1786 +/*
  1.1787 +Test the identity tan(x)=(2*tan(x/2))/(1-tan(x/2)**2) on the range low<=x<upp
  1.1788 +*/
  1.1789 +    //TReal low; // lower limit of range to test
  1.1790 +    //TReal upp; // upper limit of range to test 
  1.1791 +    {
  1.1792 +
  1.1793 +    TReal x,res,rres;
  1.1794 +
  1.1795 +    for (TInt j=0;j<100;j++)
  1.1796 +		{
  1.1797 +		if (j==90)
  1.1798 +			{
  1.1799 +			test(1);
  1.1800 +			}
  1.1801 +		randrng(x,low,upp);
  1.1802 +		test(Math::Tan(res,x)==KErrNone);
  1.1803 +		x/=2;
  1.1804 +		test(Math::Tan(rres,x)==KErrNone);
  1.1805 +		TReal ex=(2*rres)/(1-rres*rres);
  1.1806 +		test(testApprox(res,ex,1.0E-15));		
  1.1807 +		}
  1.1808 +    }
  1.1809 +
  1.1810 +LOCAL_C void tantest2()
  1.1811 +/* 
  1.1812 +To test tangent for specific  arguments 
  1.1813 +*/
  1.1814 +    {
  1.1815 +
  1.1816 +    TReal res;
  1.1817 +
  1.1818 +	// test errors
  1.1819 +	test(Math::Tan(res,KNaNTReal64)==KErrArgument);
  1.1820 +	test(Math::IsNaN(res));
  1.1821 +	test(Math::Tan(res,KPosInfTReal64)==KErrArgument);
  1.1822 +	test(Math::IsNaN(res));
  1.1823 +	test(Math::Tan(res,KNegInfTReal64)==KErrArgument);
  1.1824 +	test(Math::IsNaN(res));
  1.1825 +	test(Math::Tan(res, 1073741824.0*KPi)==KErrArgument);
  1.1826 +	test(Math::IsNaN(res));
  1.1827 +	test(Math::Tan(res, 4.0E+102)==KErrArgument);
  1.1828 +	test(Math::IsNaN(res));
  1.1829 +	test(Math::Tan(res, -4.0E+102)==KErrArgument);
  1.1830 +	test(Math::IsNaN(res));
  1.1831 +    
  1.1832 +	TInt j;
  1.1833 +	TInt mult=101;	// can use up to 32768
  1.1834 +    TInt i=sizeof(testtan)/sizeof(TAN);
  1.1835 +    for (j=0;j<i;j++)
  1.1836 +		{
  1.1837 +		test(Math::Tan(res,testtan[j].angle)==KErrNone);
  1.1838 +		test(testApprox(res,testtan[j].result,1.0E-15));		
  1.1839 +		}
  1.1840 +
  1.1841 +	//Added by AnnW, October 1996
  1.1842 +	for (j=-(mult-1); j<mult; j++)
  1.1843 +		{
  1.1844 +//		test(Math::Tan(res, (2*j+1)*KPiBy2)==KErrOverflow);
  1.1845 +//		test(Math::IsInfinite(res));	// this test is no longer valid
  1.1846 +		test(Math::Tan(res, (2*j+1)*(KPiBy2+1.0E-15))!=KErrOverflow);
  1.1847 +		test(Math::IsFinite(res));
  1.1848 +		}
  1.1849 +	
  1.1850 +	// Check that signs are correct
  1.1851 +	test(Math::Tan(res,KPiBy2+5E-16)==KErrNone);
  1.1852 +	test(res<0);
  1.1853 +	test(Math::Tan(res,KPiBy2-5E-16)==KErrNone);
  1.1854 +	test(res>0);
  1.1855 +	}
  1.1856 +
  1.1857 +LOCAL_C void tantest3()
  1.1858 +/* 
  1.1859 +To test the identity tan(-x)=-tan(x) on the range [-1.5,1.5] 
  1.1860 +*/        
  1.1861 +    {
  1.1862 +
  1.1863 +    TReal x,res,rres;
  1.1864 +
  1.1865 +    TReal low=(-1.5);
  1.1866 +    TReal upp=1.5;
  1.1867 +    for (TInt j=0;j<10;j++)
  1.1868 +		{
  1.1869 +		randrng(x,low,upp);
  1.1870 +		test(Math::Tan(res,x)==KErrNone);
  1.1871 +		x*=(-1);
  1.1872 +		test(Math::Tan(rres,x)==KErrNone);
  1.1873 +		test(testApprox(rres,-res,1.0E-15));		
  1.1874 +		}
  1.1875 +    }
  1.1876 +
  1.1877 +LOCAL_C void tantest4()
  1.1878 +/* 
  1.1879 +To test the identity tan(x)=x for x<<1 
  1.1880 +*/        
  1.1881 +    {
  1.1882 +
  1.1883 +    TReal x,res;
  1.1884 +
  1.1885 +    TReal low=1E-90;
  1.1886 +    TReal upp=1E-10;
  1.1887 +    for (TInt j=0;j<10;j++)
  1.1888 +		{
  1.1889 +		randrng(x,low,upp);
  1.1890 +		test(Math::Tan(res,x)==KErrNone);
  1.1891 +		test(testApprox(res,x,1.0E-15));		
  1.1892 +		}
  1.1893 +
  1.1894 +	// Check some denormals
  1.1895 +	test(Math::Tan(res,5E-324)==KErrNone);
  1.1896 +	test(res==5E-324);
  1.1897 +	test(Math::Tan(res,-1.234567891234E-315)==KErrNone);
  1.1898 +	test(res==-1.234567891234E-315);	
  1.1899 +    }
  1.1900 +/*
  1.1901 +LOCAL_C void tantest5()
  1.1902 +
  1.1903 +// To test that exact results are given for multiples of KPi
  1.1904 +// Added by AnnW, October 1996
  1.1905 +
  1.1906 +	{
  1.1907 +
  1.1908 +    TReal res;
  1.1909 +	TInt j;
  1.1910 +	TInt mult=101;	// can use up to 32768
  1.1911 +
  1.1912 +	test(Math::Tan(res,KNegZeroTReal64)==KErrNone);
  1.1913 +	test(res==KNegZeroTReal64);
  1.1914 +    
  1.1915 +    for (j=-(mult-1); j<mult; j++)
  1.1916 +		{
  1.1917 +		test(Math::Tan(res, j*KPi)==KErrNone);
  1.1918 +		test(res==0.0);
  1.1919 +		test(Math::Tan(res, j*(KPi+1.224E-16))==KErrNone);
  1.1920 +		test(res==0.0);
  1.1921 +		test(Math::Tan(res, (j*180)*KDegToRad)==KErrNone);
  1.1922 +		test(res==0.0);
  1.1923 +		if (j!=0)
  1.1924 +			{
  1.1925 +			test(Math::Sin(res, j*(KPi+1.0E-14))==KErrNone);
  1.1926 +			test(res!=0.0);
  1.1927 +			}
  1.1928 +		}
  1.1929 +	}
  1.1930 +*/
  1.1931 +LOCAL_C void astest1(TReal low,TReal upp,TInt k,TInt cosflg)
  1.1932 +/*
  1.1933 +Tests random numbers in the range [low,upp] using the Taylor approximation 
  1.1934 +*/
  1.1935 +    //TReal low; // lower limit of range to test
  1.1936 +    //TReal upp; // upper limit of range to test 
  1.1937 +    //TInt k; // Highest order term to be used in the taylor approximation
  1.1938 +    //TInt cosflg; // Flag for arc cos
  1.1939 +    {
  1.1940 +
  1.1941 +    TReal res,x;
  1.1942 +
  1.1943 +    for (TInt j=0;j<100;j++)
  1.1944 +		{
  1.1945 +		randrng(x,low,upp);
  1.1946 +		if (cosflg)
  1.1947 +			test(Math::ACos(res,x)==KErrNone);
  1.1948 +		else
  1.1949 +			test(Math::ASin(res,x)==KErrNone);
  1.1950 +		TReal tres=taylor(x,k);
  1.1951 +		if (cosflg)
  1.1952 +			tres=KPiBy2-tres;
  1.1953 +		test(testApprox(tres,res,5.0E-15));		
  1.1954 +		}
  1.1955 +    }
  1.1956 +
  1.1957 +LOCAL_C void astest2()
  1.1958 +/* 
  1.1959 +To test the identity arc sin(x)=x for x<<1 
  1.1960 +*/        
  1.1961 +    {
  1.1962 +
  1.1963 +    TReal x,res;
  1.1964 +
  1.1965 +    TReal low=1E-90;
  1.1966 +    TReal upp=1E-10;
  1.1967 +    for (TInt j=0;j<100;j++)
  1.1968 +		{
  1.1969 +		randrng(x,low,upp);
  1.1970 +		test(Math::ASin(res,x)==KErrNone);
  1.1971 +		test(testApprox(res,x,1.0E-15));		
  1.1972 +		}
  1.1973 +
  1.1974 +	// Check some denormals
  1.1975 +	test(Math::ASin(res,5E-324)==KErrNone);
  1.1976 +	test(res==5E-324);		
  1.1977 +	test(Math::ASin(res,-8.912345678E-318)==KErrNone);
  1.1978 +	test(res==-8.912345678E-318);		
  1.1979 +    }
  1.1980 +
  1.1981 +LOCAL_C void astest3()
  1.1982 +/* 
  1.1983 +To test the identity arc sin(-x)=-arc sin(x) 
  1.1984 +*/        
  1.1985 +    {
  1.1986 +
  1.1987 +    TReal res,rres,x;
  1.1988 +
  1.1989 +    TReal low=0.0;
  1.1990 +    TReal upp=1.0;
  1.1991 +    for (TInt j=0;j<100;j++)
  1.1992 +		{
  1.1993 +		randrng(x,low,upp);
  1.1994 +		test(Math::ASin(res,x)==KErrNone);
  1.1995 +		TReal y=(-x);
  1.1996 +		test(Math::ASin(rres,y)==KErrNone);
  1.1997 +		test(testApprox(rres,-res,1.0E-15));		
  1.1998 +		}
  1.1999 +    }
  1.2000 +
  1.2001 +LOCAL_C void astest4(TInt k,TInt sgn)
  1.2002 +/* 
  1.2003 +Test selected numbers 
  1.2004 +*/
  1.2005 +    //TInt k; // arc cosine flag
  1.2006 +    //TInt sgn; // sign flag for range    
  1.2007 +    {
  1.2008 +
  1.2009 +    TReal res;
  1.2010 +
  1.2011 +	// test errors
  1.2012 +	test(Math::ASin(res,KNaNTReal64)==KErrArgument);
  1.2013 +	test(Math::IsNaN(res));
  1.2014 +	test(Math::ASin(res,KPosInfTReal64)==KErrArgument);
  1.2015 +	test(Math::IsNaN(res));
  1.2016 +	test(Math::ASin(res,KNegInfTReal64)==KErrArgument);
  1.2017 +	test(Math::IsNaN(res));
  1.2018 +	test(Math::ASin(res,1.0000000000001)==KErrArgument);
  1.2019 +	test(Math::IsNaN(res));
  1.2020 +	test(Math::ASin(res,-1.0000000000001)==KErrArgument);
  1.2021 +	test(Math::IsNaN(res));
  1.2022 +	test(Math::ACos(res,KNaNTReal64)==KErrArgument);
  1.2023 +	test(Math::IsNaN(res));
  1.2024 +	test(Math::ACos(res,KPosInfTReal64)==KErrArgument);
  1.2025 +	test(Math::IsNaN(res));
  1.2026 +	test(Math::ACos(res,KNegInfTReal64)==KErrArgument);
  1.2027 +	test(Math::IsNaN(res));
  1.2028 +	test(Math::ACos(res,1.0000000000001)==KErrArgument);
  1.2029 +	test(Math::IsNaN(res));
  1.2030 +	test(Math::ACos(res,-1.0000000000001)==KErrArgument);
  1.2031 +	test(Math::IsNaN(res));
  1.2032 +
  1.2033 +	test(Math::ASin(res,0.0)==KErrNone);
  1.2034 +	test(res==0.0);
  1.2035 +	test(Math::ASin(res,KNegZeroTReal64)==KErrNone);
  1.2036 +	test(res==0.0);
  1.2037 +
  1.2038 +    TInt i=sizeof(testas)/sizeof(TESTASC);
  1.2039 +    for (TInt j=0;j<i;j++) 
  1.2040 +		{
  1.2041 +		// NB Results for comparison only given to 12 or 13 decimal places, so can't expect 
  1.2042 +		// better accuracy
  1.2043 +		if (k)
  1.2044 +			{
  1.2045 +			testas[j].num*=sgn;
  1.2046 +			testas[j].res*=sgn;
  1.2047 +			test(Math::ACos(res,testas[j].num)==KErrNone);
  1.2048 +			test(testApprox(res,(KPiBy2-testas[j].res),1.0E-11));	
  1.2049 +			}
  1.2050 +		else
  1.2051 +			{
  1.2052 +			test(Math::ASin(res,testas[j].num)==KErrNone);
  1.2053 +			test(testApprox(res,testas[j].res,1.0E-12));	
  1.2054 +			}
  1.2055 +		}
  1.2056 +
  1.2057 +	// Check some denormals for ACos()
  1.2058 +	test(Math::ACos(res,5E-324)==KErrNone);
  1.2059 +	test(res==KPiBy2);	
  1.2060 +	test(Math::ACos(res,-9.87654E-320)==KErrNone);
  1.2061 +	test(res==KPiBy2);						
  1.2062 +    }
  1.2063 +
  1.2064 +LOCAL_C void attest1()
  1.2065 +/* 
  1.2066 +Random argument tests for x in the primary range, comparing the result with a 
  1.2067 +Taylor series approximation
  1.2068 +*/
  1.2069 +    {
  1.2070 +
  1.2071 +    TReal res,x;
  1.2072 +
  1.2073 +    TReal low=(-0.0625);
  1.2074 +    TReal upp=0.0625;
  1.2075 +    for (TInt i=0;i<10;i++)
  1.2076 +		{
  1.2077 +		randrng(x,low,upp);
  1.2078 +		test(Math::ATan(res,x)==KErrNone);
  1.2079 +		TReal tres=tayatan(x);
  1.2080 +		test(testApprox(res,tres,1.0E-15));		
  1.2081 +		}
  1.2082 +    }
  1.2083 +
  1.2084 +LOCAL_C void attest2()
  1.2085 +/* 
  1.2086 +Random argument tests for x outside the primary range, using the identity
  1.2087 +arctan(u)=arctan(v)+arctan[(u-v)/(1+uv)]
  1.2088 +*/
  1.2089 +    {
  1.2090 +
  1.2091 +    TReal x,res,rres,atcnst;
  1.2092 +
  1.2093 +    TReal low=0.0625;
  1.2094 +    TReal upp=2.0-KSqt3;
  1.2095 +    TReal cnst=0.0625;
  1.2096 +    test(Math::ATan(atcnst,cnst)==KErrNone);
  1.2097 +    for (TInt i=0;i<10;i++)
  1.2098 +		{
  1.2099 +		randrng(x,low,upp);
  1.2100 +		test(Math::ATan(res,x)==KErrNone);
  1.2101 +		TReal y=(x-cnst)/(1+x*cnst);
  1.2102 +		test(Math::ATan(rres,y)==KErrNone);
  1.2103 +		test(testApprox(res,(atcnst+rres),1.0E-15));		
  1.2104 +		}
  1.2105 +    }                   
  1.2106 +
  1.2107 +LOCAL_C void attest3()
  1.2108 +/*
  1.2109 +Check that the identity arctan(-x)=-arctan(x) holds
  1.2110 +*/
  1.2111 +    {
  1.2112 +
  1.2113 +    TReal res,rres,x;
  1.2114 +    TReal low=0.0;
  1.2115 +    TReal upp=1.0;
  1.2116 +    for (TInt i=0;i<10;i++)
  1.2117 +		{
  1.2118 +		randrng(x,upp,low);
  1.2119 +		test(Math::ATan(res,x)==KErrNone);
  1.2120 +		x=(-x);
  1.2121 +		test(Math::ATan(rres,x)==KErrNone);
  1.2122 +		test(testApprox(res,-rres,1.0E-15));		
  1.2123 +		}
  1.2124 +    }           
  1.2125 +
  1.2126 +LOCAL_C void attest4()
  1.2127 +/* 
  1.2128 +Check that the identity arctan(x)=x for Abs(x)<1 holds
  1.2129 +*/
  1.2130 +    {
  1.2131 +
  1.2132 +    TReal x,res;
  1.2133 +
  1.2134 +    TReal low=1E-90;
  1.2135 +    TReal upp=1E-20;
  1.2136 +    for (TInt i=0;i<10;i++)
  1.2137 +		{
  1.2138 +		randrng(x,low,upp);
  1.2139 +		test(Math::ATan(res,x)==KErrNone);
  1.2140 +		test(testApprox(res,x,1.0E-15));		
  1.2141 +		}
  1.2142 +
  1.2143 +	// Check some denormals
  1.2144 +	test(Math::ATan(res,-5E-324)==KErrNone);
  1.2145 +	test(res==-5E-324);		
  1.2146 +	test(Math::ATan(res,7.123E-322)==KErrNone);
  1.2147 +	test(res==7.123E-322);			
  1.2148 +    }
  1.2149 +
  1.2150 +LOCAL_C void attest5()
  1.2151 +/*
  1.2152 +Tests selected values
  1.2153 +*/
  1.2154 +    {
  1.2155 +
  1.2156 +    TReal res;
  1.2157 +
  1.2158 +	// test errors, special cases
  1.2159 +	test(Math::ATan(res,KNaNTReal64)==KErrArgument);
  1.2160 +	test(Math::IsNaN(res));
  1.2161 +	test(Math::ATan(res,0.0)==KErrNone);
  1.2162 +	test(res==0.0);
  1.2163 +	test(Math::ATan(res,KNegZeroTReal64)==KErrNone);
  1.2164 +	test(res==0.0);
  1.2165 +	test(Math::ATan(res,KPosInfTReal64)==KErrNone);
  1.2166 +	test(res==KPiBy2);
  1.2167 +	test(Math::ATan(res,KNegInfTReal64)==KErrNone);
  1.2168 +	test(res==-KPiBy2);
  1.2169 +
  1.2170 +	test(Math::ATan(res,KNaNTReal64,1.0)==KErrArgument);
  1.2171 +	test(Math::IsNaN(res));
  1.2172 +	test(Math::ATan(res,1.0,KNaNTReal64)==KErrArgument);
  1.2173 +	test(Math::IsNaN(res));
  1.2174 +	test(Math::ATan(res,KNaNTReal64,KNaNTReal64)==KErrArgument);
  1.2175 +	test(Math::IsNaN(res));
  1.2176 +	test(Math::ATan(res,0.0,KNegZeroTReal64)==KErrArgument);
  1.2177 +	test(Math::IsNaN(res));
  1.2178 +	test(Math::ATan(res,KNegZeroTReal64,KNegZeroTReal64)==KErrArgument);
  1.2179 +	test(Math::IsNaN(res));	
  1.2180 +	test(Math::ATan(res,0.0,0.0)==KErrArgument);
  1.2181 +	test(Math::IsNaN(res));	
  1.2182 +	test(Math::ATan(res,KNegZeroTReal64,KNegZeroTReal64)==KErrArgument);
  1.2183 +	test(Math::IsNaN(res));	
  1.2184 +	test(Math::ATan(res,KPosInfTReal64,KNegInfTReal64)==KErrNone);
  1.2185 +	test(res==3.0*(KPiBy2/2.0));
  1.2186 +	test(Math::ATan(res,KPosInfTReal64,KPosInfTReal64)==KErrNone);
  1.2187 +	test(res==KPiBy2/2.0);
  1.2188 +	test(Math::ATan(res,KNegInfTReal64,KPosInfTReal64)==KErrNone);
  1.2189 +	test(res==-(KPiBy2/2.0));
  1.2190 +	test(Math::ATan(res,KNegInfTReal64,KNegInfTReal64)==KErrNone);
  1.2191 +	test(res==-3.0*(KPiBy2/2.0));
  1.2192 +	test(Math::ATan(res,KNegZeroTReal64,1.0)==KErrNone);
  1.2193 +	test(res==0.0);
  1.2194 +	test(Math::ATan(res,0.0,1.0)==KErrNone);
  1.2195 +	test(res==0.0);	
  1.2196 +	test(Math::ATan(res,0.0,-1.0)==KErrNone);
  1.2197 +	test(res==KPi);	
  1.2198 +	test(Math::ATan(res,1.0,KPosInfTReal64)==KErrNone);
  1.2199 +	test(res==0.0);
  1.2200 +	test(Math::ATan(res,1.0,KNegInfTReal64)==KErrNone);
  1.2201 +	test(res==KPi);
  1.2202 +	test(Math::ATan(res,0.0,KPosInfTReal64)==KErrNone);	
  1.2203 +	test(res==0.0);
  1.2204 +	test(Math::ATan(res,KPosInfTReal64,1.0)==KErrNone);	
  1.2205 +	test(res==KPiBy2);
  1.2206 +	test(Math::ATan(res,KNegInfTReal64,1.0)==KErrNone);	
  1.2207 +	test(res==-KPiBy2);
  1.2208 +	test(Math::ATan(res,1.0,0.0)==KErrNone);	
  1.2209 +	test(res==KPiBy2);
  1.2210 +	test(Math::ATan(res,1.0,KNegZeroTReal64)==KErrNone);	
  1.2211 +	test(res==KPiBy2);
  1.2212 +	test(Math::ATan(res,KPosInfTReal64,-1.0)==KErrNone);	
  1.2213 +	test(res==KPiBy2);
  1.2214 +	test(Math::ATan(res,KNegInfTReal64,-1.0)==KErrNone);	
  1.2215 +	test(res==-KPiBy2);
  1.2216 +	test(Math::ATan(res,-1.0,0.0)==KErrNone);	
  1.2217 +	test(res==-KPiBy2);
  1.2218 +	test(Math::ATan(res,-1.0,KNegZeroTReal64)==KErrNone);	
  1.2219 +	test(res==-KPiBy2);
  1.2220 +	test(Math::ATan(res,5E-324,10)==KErrNone);	
  1.2221 +	test(res==0.0);
  1.2222 +	test(Math::ATan(res,1E+308,0.1)==KErrNone);	
  1.2223 +	test(res==KPiBy2);
  1.2224 +
  1.2225 +    TInt i=sizeof(testat2)/sizeof(TESTATAN2);
  1.2226 +    for (TInt j=0;j<i;j++) 
  1.2227 +		{
  1.2228 +		// NB Some results only given to 12 dp so cannot expect better accuracy
  1.2229 +		test(Math::ATan(res,testat2[j].num1,testat2[j].num2)==KErrNone);
  1.2230 +		test(testApprox(res,testat2[j].res,1.0E-12));		
  1.2231 +		}	
  1.2232 +    }
  1.2233 +
  1.2234 +LOCAL_C void inttest1()
  1.2235 +/*
  1.2236 +Tests specific numbers
  1.2237 +*/
  1.2238 +    {
  1.2239 +
  1.2240 +    TReal res;
  1.2241 +
  1.2242 +	// Specials
  1.2243 +	test(Math::Int(res,KNaNTReal64)==KErrArgument);
  1.2244 +	test(Math::IsNaN(res));
  1.2245 +	test(Math::Int(res,KPosInfTReal64)==KErrOverflow);
  1.2246 +	test(res==KPosInfTReal64);
  1.2247 +	test(Math::Int(res,KNegInfTReal64)==KErrOverflow);
  1.2248 +	test(res==KNegInfTReal64);
  1.2249 +
  1.2250 +    TInt i=sizeof(testint1)/sizeof(INT_TEST);
  1.2251 +    for (TInt j=0;j<i;j++) 
  1.2252 +		{
  1.2253 +		test(Math::Int(res,testint1[j].num)==KErrNone);
  1.2254 +		test(res==testint1[j].res);
  1.2255 +		}
  1.2256 +
  1.2257 +	// Check some denormals
  1.2258 +	test(Math::Int(res,5E-324)==KErrNone);
  1.2259 +	test(res==0.0);
  1.2260 +	test(Math::Int(res,1.45E-309)==KErrNone);
  1.2261 +	test(res==0.0);
  1.2262 +    }
  1.2263 +
  1.2264 +LOCAL_C void inttest2()
  1.2265 +/*
  1.2266 +Tests specific numbers
  1.2267 +*/
  1.2268 +    {
  1.2269 +
  1.2270 +    TInt16 res;
  1.2271 +
  1.2272 +	// test errors
  1.2273 +	test(Math::Int(res,KNaNTReal64)==KErrArgument);
  1.2274 +	test(res==0);
  1.2275 +	test(Math::Int(res,KPosInfTReal64)==KErrOverflow);
  1.2276 +	test(res==TInt16(KMaxTInt16));	
  1.2277 +	test(Math::Int(res,32768.9830857)==KErrOverflow);
  1.2278 +	test(res==TInt16(KMaxTInt16));
  1.2279 +	test(Math::Int(res,32769.36946)==KErrOverflow);
  1.2280 +	test(res==TInt16(KMaxTInt16));
  1.2281 +	test(Math::Int(res,KNegInfTReal64)==KErrUnderflow);
  1.2282 +    test(res==TInt16(KMinTInt16));
  1.2283 +	test(Math::Int(res,-32774.997937)==KErrUnderflow);
  1.2284 +    test(res==TInt16(KMinTInt16));
  1.2285 +
  1.2286 +    TInt i=sizeof(testint2)/sizeof(INTI_TEST);
  1.2287 +    for (TInt j=0;j<i;j++) 
  1.2288 +		{
  1.2289 +		test(Math::Int(res,testint2[j].num)==KErrNone);
  1.2290 +		test(res==testint2[j].res);		
  1.2291 +		}
  1.2292 +
  1.2293 +	// Check some denormals
  1.2294 +	test(Math::Int(res,5E-324)==KErrNone);
  1.2295 +	test(res==0.0);
  1.2296 +	test(Math::Int(res,1.45E-309)==KErrNone);
  1.2297 +	test(res==0.0);
  1.2298 +	}
  1.2299 +
  1.2300 +LOCAL_C void inttest3()
  1.2301 +/*
  1.2302 +Tests specific numbers
  1.2303 +*/
  1.2304 +    {
  1.2305 +
  1.2306 +    TInt32 res;
  1.2307 +
  1.2308 +    // test errors
  1.2309 +	test(Math::Int(res,KNaNTReal64)==KErrArgument);
  1.2310 +	test(res==0);
  1.2311 +	test(Math::Int(res,KPosInfTReal64)==KErrOverflow);
  1.2312 +	test(res==KMaxTInt32);
  1.2313 +	test(Math::Int(res,2147483648.34576)==KErrOverflow);
  1.2314 +	test(res==KMaxTInt32);
  1.2315 +    test(Math::Int(res,2147553576.8794365)==KErrOverflow);
  1.2316 +	test(res==KMaxTInt32);
  1.2317 +    test(Math::Int(res,KNegInfTReal64)==KErrUnderflow);
  1.2318 +	test(res==KMinTInt32);
  1.2319 +	test(Math::Int(res,-2147496757.583)==KErrUnderflow);
  1.2320 +	test(res==KMinTInt32);
  1.2321 +    
  1.2322 +	TInt i=sizeof(testint3)/sizeof(INTL_TEST);
  1.2323 +    for (TInt j=0;j<i;j++) 
  1.2324 +		{
  1.2325 +		test(Math::Int(res,testint3[j].num)==KErrNone);
  1.2326 +		test(res==testint3[j].res);
  1.2327 +		}
  1.2328 +
  1.2329 +	// Check some denormals
  1.2330 +	test(Math::Int(res,5E-324)==KErrNone);
  1.2331 +	test(res==0.0);
  1.2332 +	test(Math::Int(res,1.45E-309)==KErrNone);
  1.2333 +	test(res==0.0);
  1.2334 +	}
  1.2335 +
  1.2336 +LOCAL_C void inttest4()
  1.2337 +	{
  1.2338 +	// tests Int()
  1.2339 +	TInt16 tint16;
  1.2340 +	TInt32 tint32;
  1.2341 +	TReal trg,src=100.0;
  1.2342 +
  1.2343 +	test.Start(_L("Math::Int()"));
  1.2344 +	src=0.0;
  1.2345 +	test(Math::Int(trg,src)==KErrNone);  
  1.2346 +	test(trg==0.0);
  1.2347 +	test(Math::Int(tint16,src)==KErrNone);
  1.2348 +	test(tint16==0);
  1.2349 +	test(Math::Int(tint32,src)==KErrNone);
  1.2350 +	test(tint32==0);
  1.2351 +
  1.2352 +    src=0.1233456789;
  1.2353 +	test(Math::Int(trg,src)==KErrNone);  
  1.2354 +	test(trg==0.0);
  1.2355 +	test(Math::Int(tint16,src)==KErrNone);
  1.2356 +	test(tint16==0);
  1.2357 +	test(Math::Int(tint32,src)==KErrNone);
  1.2358 +	test(tint32==0);
  1.2359 +
  1.2360 +	src=-0.5;
  1.2361 +	test(Math::Int(trg,src)==KErrNone);  
  1.2362 +	test(trg==0.0);
  1.2363 +	test(Math::Int(tint16,src)==KErrNone);
  1.2364 +	test(tint16==0);
  1.2365 +	test(Math::Int(tint32,src)==KErrNone);
  1.2366 +	test(tint32==0);
  1.2367 +
  1.2368 +	src=1.123456789;
  1.2369 +	test(Math::Int(trg,src)==KErrNone);  
  1.2370 +	test(trg==1.0);
  1.2371 +	test(Math::Int(tint16,src)==KErrNone);
  1.2372 +	test(tint16==1);
  1.2373 +	test(Math::Int(tint32,src)==KErrNone);
  1.2374 +	test(tint32==1);
  1.2375 +
  1.2376 +	src=-1.12345678;
  1.2377 +	test(Math::Int(trg,src)==KErrNone);  
  1.2378 +	test(trg==-1.0);
  1.2379 +	test(Math::Int(tint16,src)==KErrNone);
  1.2380 +	test(tint16==-1);
  1.2381 +	test(Math::Int(tint32,src)==KErrNone);
  1.2382 +	test(tint32==-1);
  1.2383 +
  1.2384 +	src=KMaxTInt16-0.1; 
  1.2385 +	test(Math::Int(trg,src)==KErrNone);  
  1.2386 +	test(trg==KMaxTInt16-1);
  1.2387 +	test(Math::Int(tint16,src)==KErrNone);
  1.2388 +	test(tint16==KMaxTInt16-1);
  1.2389 +	test(Math::Int(tint32,src)==KErrNone);
  1.2390 +	test(tint32==KMaxTInt16-1);
  1.2391 +
  1.2392 +	src=KMaxTInt16+0.5; 
  1.2393 +	test(Math::Int(trg,src)==KErrNone);  
  1.2394 +	test(trg==KMaxTInt16);
  1.2395 +	test(Math::Int(tint16,src)==KErrNone);
  1.2396 +	test(tint16==KMaxTInt16);
  1.2397 +	test(Math::Int(tint32,src)==KErrNone);
  1.2398 +	test(tint32==KMaxTInt16);
  1.2399 +
  1.2400 +	src=KMaxTInt16+1; 
  1.2401 +	test(Math::Int(trg,src)==KErrNone);  
  1.2402 +	test(trg==KMaxTInt16+1);
  1.2403 +	test(Math::Int(tint16,src)==KErrOverflow);
  1.2404 +	test(Math::Int(tint32,src)==KErrNone);
  1.2405 +	test(tint32==KMaxTInt16+1);
  1.2406 +
  1.2407 +	src=KMinTInt16-0.1; 
  1.2408 +	test(Math::Int(trg,src)==KErrNone);  
  1.2409 +	test(trg==KMinTInt16);
  1.2410 +	test(Math::Int(tint16,src)==KErrNone);
  1.2411 +	test(tint16==KMinTInt16);
  1.2412 +	test(Math::Int(tint32,src)==KErrNone);
  1.2413 +	test(tint32==KMinTInt16);
  1.2414 +
  1.2415 +	src=KMinTInt16; 
  1.2416 +	test(Math::Int(trg,src)==KErrNone);  
  1.2417 +	test(trg==KMinTInt16);
  1.2418 +	test(Math::Int(tint16,src)==KErrNone);
  1.2419 +	test(tint16==KMinTInt16);
  1.2420 +	test(Math::Int(tint32,src)==KErrNone);
  1.2421 +	test(tint32==KMinTInt16);
  1.2422 +
  1.2423 +	src=KMinTInt16-1; 
  1.2424 +	test(Math::Int(trg,src)==KErrNone);  
  1.2425 +	test(trg==KMinTInt16-1);
  1.2426 +	test(Math::Int(tint16,src)==KErrUnderflow);
  1.2427 +	test(Math::Int(tint32,src)==KErrNone);
  1.2428 +	test(tint32==KMinTInt16-1);
  1.2429 +
  1.2430 +	src=KMaxTInt32-0.1; 
  1.2431 +	test(Math::Int(trg,src)==KErrNone);  
  1.2432 +	test(trg==KMaxTInt32-1);
  1.2433 +	test(Math::Int(tint16,src)==KErrOverflow);
  1.2434 +	test(Math::Int(tint32,src)==KErrNone);
  1.2435 +	test(tint32==KMaxTInt32-1);
  1.2436 +
  1.2437 +	src=KMaxTInt32+0.5; 
  1.2438 +	test(Math::Int(trg,src)==KErrNone);  
  1.2439 +	test(trg==KMaxTInt32);
  1.2440 +	test(Math::Int(tint16,src)==KErrOverflow);
  1.2441 +	test(Math::Int(tint32,src)==KErrNone);
  1.2442 +	test(tint32==KMaxTInt32);
  1.2443 +
  1.2444 +	src=KMaxTInt32; 
  1.2445 +	src+=1;
  1.2446 +	test(Math::Int(trg,src)==KErrNone);  
  1.2447 +	test(trg==(TUint32)KMaxTInt32+1);
  1.2448 +	test(Math::Int(tint16,src)==KErrOverflow);
  1.2449 +	test(Math::Int(tint32,src)==KErrOverflow);
  1.2450 +
  1.2451 +	src=KMinTInt32+0.1; 
  1.2452 +	test(Math::Int(trg,src)==KErrNone);  
  1.2453 +	test(trg==KMinTInt32+1);
  1.2454 +	test(Math::Int(tint16,src)==KErrUnderflow);
  1.2455 +	test(Math::Int(tint32,src)==KErrNone);
  1.2456 +	test(tint32==KMinTInt32+1);
  1.2457 +
  1.2458 +	src=KMinTInt32; 
  1.2459 +	test(Math::Int(trg,src)==KErrNone);  
  1.2460 +	test(trg==KMinTInt32);
  1.2461 +	test(Math::Int(tint16,src)==KErrUnderflow);
  1.2462 +	test(Math::Int(tint32,src)==KErrNone);
  1.2463 +	test(tint32==KMinTInt32);
  1.2464 +
  1.2465 +	src=KMinTInt32;
  1.2466 +	src-=1; 
  1.2467 +	test(Math::Int(trg,src)==KErrNone);  
  1.2468 +	test((trg+1)==KMinTInt32);
  1.2469 +	test(Math::Int(tint16,src)==KErrUnderflow);
  1.2470 +	test(Math::Int(tint32,src)==KErrUnderflow);
  1.2471 +
  1.2472 +	src=KMaxTUint32-0.1;
  1.2473 +	test(Math::Int(trg,src)==KErrNone);  
  1.2474 +	test(trg==KMaxTUint32-1);
  1.2475 +	test(Math::Int(tint16,src)==KErrOverflow);
  1.2476 +	test(Math::Int(tint32,src)==KErrOverflow);
  1.2477 +
  1.2478 +	src=KMaxTUint32;
  1.2479 +	test(Math::Int(trg,src)==KErrNone);  
  1.2480 +	test(trg==KMaxTUint32);
  1.2481 +	test(Math::Int(tint16,src)==KErrOverflow);
  1.2482 +	test(Math::Int(tint32,src)==KErrOverflow);
  1.2483 +
  1.2484 +	test.End();
  1.2485 +	}
  1.2486 +
  1.2487 +LOCAL_C void fractest1()
  1.2488 +/*
  1.2489 +Tests specific numbers
  1.2490 +*/
  1.2491 +    {
  1.2492 +
  1.2493 +    TReal res;
  1.2494 +
  1.2495 +	// test errors
  1.2496 +	test(Math::Frac(res,KNaNTReal64)==KErrArgument);
  1.2497 +	test(Math::IsNaN(res));
  1.2498 +	test(Math::Frac(res,KPosInfTReal64)==KErrOverflow);
  1.2499 +	test(res==0.0);
  1.2500 +	test(Math::Frac(res,KNegInfTReal64)==KErrOverflow);
  1.2501 +	test(res==0.0);
  1.2502 +
  1.2503 +    TInt i=sizeof(testfrac)/sizeof(FRAC_TEST);
  1.2504 +    for (TInt j=0;j<i;j++) 
  1.2505 +		{
  1.2506 +		test(Math::Frac(res,testfrac[j].num)==KErrNone);
  1.2507 +		TReal err=(res-testfrac[j].res);
  1.2508 +		if (res)
  1.2509 +			err/=testfrac[j].num;	// NB num not res
  1.2510 +		test(Abs(err)<1.0E-15);
  1.2511 +		}
  1.2512 +
  1.2513 +	// Check some denormals
  1.2514 +	test(Math::Frac(res,5E-324)==KErrNone);
  1.2515 +	test(res==5E-324);
  1.2516 +	test(Math::Frac(res,1.23456789E-314)==KErrNone);
  1.2517 +	test(res==1.23456789E-314);
  1.2518 +    }
  1.2519 +
  1.2520 +LOCAL_C void fractest2()
  1.2521 +	{
  1.2522 +	// tests Frac() 
  1.2523 +	test.Start(_L("Math::Frac()"));
  1.2524 +	TReal trg,src;
  1.2525 +
  1.2526 +	src=0.0;
  1.2527 +	test(Math::Frac(trg,src)==KErrNone);
  1.2528 +	test(trg==0.0);
  1.2529 +
  1.2530 +	src=0.1;
  1.2531 +	test(Math::Frac(trg,src)==KErrNone);
  1.2532 +	test(trg==0.1);
  1.2533 +
  1.2534 +	src=-0.1;
  1.2535 +	test(Math::Frac(trg,src)==KErrNone);
  1.2536 +	test(trg==-0.1);
  1.2537 +
  1.2538 +	src=7.5;
  1.2539 +	test(Math::Frac(trg,src)==KErrNone);
  1.2540 +	test(trg==0.5);
  1.2541 +
  1.2542 +	src=-7.5;
  1.2543 +	test(Math::Frac(trg,src)==KErrNone);
  1.2544 +	test(trg==-0.5);
  1.2545 +
  1.2546 +	src=5.998046875;
  1.2547 +	test(Math::Frac(trg,src)==KErrNone);
  1.2548 +	test(trg==0.998046875);
  1.2549 +
  1.2550 +	src=-5.998046875;
  1.2551 +	test(Math::Frac(trg,src)==KErrNone);
  1.2552 +	test(trg==-0.998046875);
  1.2553 +
  1.2554 +	src=-0.00000000001;
  1.2555 +	test(Math::Frac(trg,src)==KErrNone);
  1.2556 +	test(trg==-0.00000000001);
  1.2557 +
  1.2558 +	src=1000000000000.5;
  1.2559 +	test(Math::Frac(trg,src)==KErrNone);
  1.2560 +	test(trg==0.5);
  1.2561 +
  1.2562 +	src=1099511627776.0;
  1.2563 +	src+=0.000244140625;
  1.2564 +	test(Math::Frac(trg,src)==KErrNone);
  1.2565 +	test(trg==0.000244140625);
  1.2566 +
  1.2567 +	src=-KMaxTInt32;
  1.2568 +	src+=0.5;
  1.2569 +	test(Math::Frac(trg,src)==KErrNone);
  1.2570 +	test(trg==-0.5);
  1.2571 +
  1.2572 +	src=KMaxTUint32;
  1.2573 +	src+=0.5;
  1.2574 +	test(Math::Frac(trg,src)==KErrNone);
  1.2575 +	test(trg==0.5);
  1.2576 +
  1.2577 +	test.End();
  1.2578 +	}
  1.2579 +
  1.2580 +LOCAL_C void modtest1()
  1.2581 +/*
  1.2582 +Test modulo function using specified values
  1.2583 +*/
  1.2584 +    {
  1.2585 +
  1.2586 +    TReal res;
  1.2587 +
  1.2588 +	// test errors
  1.2589 +	test(Math::Mod(res,KNaNTReal64,1.0)==KErrArgument);
  1.2590 +	test(Math::IsNaN(res));
  1.2591 +	test(Math::Mod(res,1.0,KNaNTReal64)==KErrArgument);
  1.2592 +	test(Math::IsNaN(res));
  1.2593 +	test(Math::Mod(res,KNaNTReal64,KNaNTReal64)==KErrArgument);
  1.2594 +	test(Math::IsNaN(res));
  1.2595 +	test(Math::Mod(res,KPosInfTReal64,2.0)==KErrArgument);
  1.2596 +	test(Math::IsNaN(res));
  1.2597 +	test(Math::Mod(res,KNegInfTReal64,2.0)==KErrArgument);
  1.2598 +	test(Math::IsNaN(res));
  1.2599 +	test(Math::Mod(res,2.0,KNegZeroTReal64)==KErrArgument);
  1.2600 +	test(Math::IsNaN(res));
  1.2601 +	test(Math::Mod(res,1.0,0.0)==KErrArgument);
  1.2602 +	test(Math::IsNaN(res));
  1.2603 +
  1.2604 +    TInt i=sizeof(testmod)/sizeof(MOD_TEST);
  1.2605 +    for (TInt j=0;j<i;j++) 
  1.2606 +		{
  1.2607 +		test(Math::Mod(res,testmod[j].num,testmod[j].mod)==KErrNone);
  1.2608 +		test(testApprox(res,testmod[j].res,5.0E-13));		
  1.2609 +		}
  1.2610 +
  1.2611 +	// Check some denormals
  1.2612 + 	test(Math::Mod(res,K1Point2EMinus320Real64,K5EMinus321Real64)==KErrNone);
  1.2613 + 	test(res==K2EMinus321Real64);		
  1.2614 + 	test(Math::Mod(res,K1Point234EMinus316Real64,K1Point234EMinus316Real64)==KErrNone);
  1.2615 +	test(res==0.0);		
  1.2616 +    }
  1.2617 +
  1.2618 +LOCAL_C void modtest2()
  1.2619 +/*
  1.2620 +Test modulo function for values which will be incorrect so return KErrTotalLossOfPrecision
  1.2621 +*/
  1.2622 +    {
  1.2623 +
  1.2624 +    TReal res;
  1.2625 +
  1.2626 +	TInt i=sizeof(testmod2)/sizeof(MOD_TEST);
  1.2627 +    for (TInt j=0;j<i;j++) 
  1.2628 +		{
  1.2629 +		test(Math::Mod(res,testmod2[j].num,testmod2[j].mod)==KErrTotalLossOfPrecision);
  1.2630 +		test(Math::IsZero(res));
  1.2631 +		}
  1.2632 +	}
  1.2633 +
  1.2634 +LOCAL_C void DuplicateTest()
  1.2635 +//
  1.2636 +// Tests that you can use the same variable for both operands in some Math functions
  1.2637 +// NB results only given to 12 or 13 significant figures so cannot expect better accuracy
  1.2638 +//
  1.2639 +	{
  1.2640 +
  1.2641 +	TReal inOut;
  1.2642 +	test.Start(_L("ACos"));
  1.2643 +	inOut=-0.5;
  1.2644 +	test(Math::ACos(inOut,inOut)==KErrNone);
  1.2645 +	test(testApprox(inOut,2.094395102393,1.0E-13));			
  1.2646 +
  1.2647 +	test.Next(_L("ASin"));
  1.2648 +	inOut=-0.5;
  1.2649 +	test(Math::ASin(inOut,inOut)==KErrNone);
  1.2650 +	test(testApprox(inOut,-0.523598775598,6.0E-13));			
  1.2651 +
  1.2652 +	test.Next(_L("ATan"));
  1.2653 +	inOut=0.5;
  1.2654 +	test(Math::ATan(inOut,inOut)==KErrNone);
  1.2655 +	test(testApprox(inOut,0.463647609001,5.0E-13));			
  1.2656 +	inOut=-0.25;
  1.2657 +	TReal another=-0.5;
  1.2658 +	test(Math::ATan(inOut,inOut,another)==KErrNone);
  1.2659 +	test(testApprox(inOut,-2.677945044589,5.0E-15));			
  1.2660 +	inOut=-0.5;
  1.2661 +	another=0.25;
  1.2662 +	test(Math::ATan(inOut,another,inOut)==KErrNone);
  1.2663 +	test(testApprox(inOut,2.677945044589,5.0E-15));			
  1.2664 +
  1.2665 +	test.Next(_L("Cos"));
  1.2666 +	inOut=1;
  1.2667 +	test(Math::Cos(inOut,inOut)==KErrNone);
  1.2668 +	test(testApprox(inOut,0.540302305868,3.0E-13));			
  1.2669 +
  1.2670 +	test.Next(_L("Exp"));
  1.2671 +	inOut=0.5;
  1.2672 +	test(Math::Exp(inOut,inOut)==KErrNone);
  1.2673 +	test(testApprox(inOut,1.648721270700,1.0E-13));			
  1.2674 +
  1.2675 +	test.Next(_L("Frac"));
  1.2676 +	inOut=56.123456789;
  1.2677 +	test(Math::Frac(inOut,inOut)==KErrNone);
  1.2678 +	test(testApprox(inOut,0.123456789,2.0E-14));
  1.2679 +
  1.2680 +	test.Next(_L("Int"));
  1.2681 +	inOut=56.123456789;
  1.2682 +	test(Math::Int(inOut,inOut)==KErrNone);
  1.2683 +	test(inOut==56);
  1.2684 +	
  1.2685 +	test.Next(_L("Log"));
  1.2686 +	inOut=0.5;
  1.2687 +	test(Math::Log(inOut,inOut)==KErrNone);
  1.2688 +	test(testApprox(inOut,-0.301029995664,7.0E-14));				
  1.2689 +
  1.2690 +	test.Next(_L("Ln"));
  1.2691 +	inOut=0.5;
  1.2692 +	test(Math::Ln(inOut,inOut)==KErrNone);
  1.2693 +	test(testApprox(inOut,-0.693147180560,8.0E-14));				
  1.2694 +
  1.2695 +	test.Next(_L("Mod"));
  1.2696 +	inOut=53;
  1.2697 +	another=17;
  1.2698 +	test(Math::Mod(inOut,inOut,another)==KErrNone);
  1.2699 +	test(inOut==2);
  1.2700 +	inOut=17;
  1.2701 +	another=53;
  1.2702 +	test(Math::Mod(inOut,another,inOut)==KErrNone);
  1.2703 +	test(inOut==2);
  1.2704 +
  1.2705 +	test.Next(_L("Pow"));
  1.2706 +	inOut=-5;
  1.2707 +	another=3;
  1.2708 +	test(Math::Pow(inOut,inOut,another)==KErrNone);
  1.2709 +	test(inOut==-125.0);
  1.2710 +	another=-5;
  1.2711 +	inOut=3;
  1.2712 +	test(Math::Pow(inOut,another,inOut)==KErrNone);
  1.2713 +	test(inOut==-125.0);
  1.2714 +
  1.2715 +	test.Next(_L("Sin"));
  1.2716 +	inOut=1;
  1.2717 +	test(Math::Sin(inOut,inOut)==KErrNone);
  1.2718 +	test(testApprox(inOut,0.84147098480790,5.0E-15));				
  1.2719 +
  1.2720 +	test.Next(_L("Round"));
  1.2721 +	inOut=123.4567;
  1.2722 +	test(Math::Round(inOut,inOut,2)==KErrNone);
  1.2723 +	test(testApprox(inOut,123.46,1.0E-15));				
  1.2724 +
  1.2725 +	test.Next(_L("Sqrt"));
  1.2726 +	inOut=53;
  1.2727 +	test(Math::Sqrt(inOut,inOut)==KErrNone);
  1.2728 +	test(testApprox(inOut,7.280109889281,7.0E-14));				
  1.2729 +
  1.2730 +	test.Next(_L("Tan"));
  1.2731 +	inOut=1;
  1.2732 +	test(Math::Tan(inOut,inOut)==KErrNone);
  1.2733 +	test(testApprox(inOut,1.557407724655,7.0E-14));				
  1.2734 +
  1.2735 +	test.End();
  1.2736 +	}
  1.2737 +
  1.2738 +LOCAL_C void specialtest()
  1.2739 +//
  1.2740 +// Tests functions which test for specials
  1.2741 +// 
  1.2742 +	{
  1.2743 +
  1.2744 +	test(Math::IsZero(0.0));
  1.2745 +	test(Math::IsZero(KNegZeroTReal64));
  1.2746 +	test(Math::IsZero(0.0));
  1.2747 +	test(!Math::IsZero(1.0));
  1.2748 +	test(!Math::IsZero(KPosInfTReal64));
  1.2749 +	test(!Math::IsZero(KNaNTReal64));
  1.2750 + 	test(!Math::IsZero(K5EMinus324Real64));
  1.2751 +
  1.2752 +	test(Math::IsNaN(KNaNTReal64));
  1.2753 +	test(!Math::IsNaN(KPosInfTReal64));
  1.2754 +	test(!Math::IsNaN(KNegInfTReal64));
  1.2755 +	test(!Math::IsNaN(0.0));
  1.2756 +	test(!Math::IsNaN(1.0));
  1.2757 +
  1.2758 +	test(Math::IsInfinite(KPosInfTReal64));
  1.2759 +	test(Math::IsInfinite(KNegInfTReal64));
  1.2760 +	test(!Math::IsInfinite(KNaNTReal64));
  1.2761 +	test(!Math::IsInfinite(0.0));
  1.2762 +	test(!Math::IsInfinite(KMaxTReal64));
  1.2763 +
  1.2764 +	test(!Math::IsFinite(KPosInfTReal64));
  1.2765 +	test(!Math::IsFinite(KNegInfTReal64));
  1.2766 +	test(!Math::IsFinite(KNaNTReal64));
  1.2767 +	test(Math::IsFinite(0.0));
  1.2768 +	test(Math::IsFinite(KMaxTReal64));
  1.2769 +	test(Math::IsFinite(5E-324));	
  1.2770 +	test(Math::IsFinite(1.0));
  1.2771 +	}
  1.2772 +
  1.2773 +void _matherr(TExcType aType)
  1.2774 +//
  1.2775 +// Dummy function to handle exceptions
  1.2776 +//
  1.2777 +	{
  1.2778 +
  1.2779 +	test.Printf(_L("_matherr: Exception type %u handled\n"),TUint(aType));
  1.2780 +	}
  1.2781 +
  1.2782 +#ifdef __GCC32__
  1.2783 +#define FSTCW(x) asm("mov eax, %0\nfstcw [eax]": : "i"(&x))
  1.2784 +#define FLDCW(x) asm("mov eax, %0\nfldcw [eax]": : "i"(&x))
  1.2785 +#else
  1.2786 +#define FSTCW(x) _asm fstcw x
  1.2787 +#define FLDCW(x) _asm fldcw x
  1.2788 +#endif
  1.2789 +TInt16 cw=0; // must be global or GCC/GAS can't get the address!
  1.2790 +
  1.2791 +GLDEF_C TInt E32Main()
  1.2792 +    {     
  1.2793 +
  1.2794 +#if defined (__X86__)
  1.2795 +	FSTCW(cw);
  1.2796 +	test.Printf(_L("control word = 0x%x\n"),cw);
  1.2797 +	cw=0x27f;	// WINS value
  1.2798 +	FLDCW(cw);
  1.2799 +#endif
  1.2800 +
  1.2801 +	test.Title();
  1.2802 +
  1.2803 +	test.Start(_L("Assorted tests"));
  1.2804 +	AssortedTests();
  1.2805 +
  1.2806 +	test.Next(_L("sqrtest1(KSqhf,1.0)"));
  1.2807 +    sqrtest1(KSqhf,1.0);
  1.2808 +	test.Next(_L("sqrtest1(1.0,1.41421356238)"));
  1.2809 +    sqrtest1(1.0,1.41421356238);
  1.2810 +	test.Next(_L("sqrtest2"));
  1.2811 +    sqrtest2();                  
  1.2812 +
  1.2813 +	test.Next(_L("logtest"));
  1.2814 +    logtest();
  1.2815 +	test.Next(_L("lntest1"));
  1.2816 +    lntest1();
  1.2817 +	test.Next(_L("lntest2"));
  1.2818 +    lntest2();
  1.2819 +	test.Next(_L("lntest3"));
  1.2820 +    lntest3();
  1.2821 +	test.Next(_L("lntest4"));
  1.2822 +    lntest4();
  1.2823 +
  1.2824 +	test.Next(_L("exptest1"));
  1.2825 +    exptest1();
  1.2826 +	test.Next(_L("exptest2(-0.0625,-.9375,1.0625)"));
  1.2827 +    exptest2(-0.0625,-0.9375,1.0625);
  1.2828 +	test.Next(_L("exptest2(-29.0/16.0),1.0,88.0)"));
  1.2829 +    exptest2((-29.0/16.0),1.0,88.0);
  1.2830 +	test.Next(_L("exptest2(-29.0/16.0),-1.0,-88.0)"));
  1.2831 +    exptest2((-29.0/16.0),-1.0,-88.0);
  1.2832 +	test.Next(_L("exptest3"));
  1.2833 +    exptest3();
  1.2834 +
  1.2835 +	test.Next(_L("powtest1"));
  1.2836 +    powtest1();
  1.2837 +	test.Next(_L("powtest2(.5,1.0)"));
  1.2838 +    powtest2(.5,1.0);
  1.2839 +	test.Next(_L("powtest2(1.0,1.0E33)"));
  1.2840 +    powtest2(1.0,1.0E33);
  1.2841 +	test.Next(_L("powtest3"));
  1.2842 +    powtest3();
  1.2843 +	test.Next(_L("powtest4"));
  1.2844 +    powtest4();
  1.2845 +	test.Next(_L("powtest5"));
  1.2846 +    powtest5();
  1.2847 +	test.Next(_L("powtest6"));
  1.2848 +    powtest6();
  1.2849 +	
  1.2850 +	test.Next(_L("pow10test"));
  1.2851 +	pow10test();
  1.2852 +														
  1.2853 +	test.Next(_L("sintest1(3*KPi,3.5*KPi)"));
  1.2854 +    sintest1(3*KPi,3.5*KPi);
  1.2855 +	test.Next(_L("sintest1(3*KPi,3.5*KPi)"));
  1.2856 +    sintest1(6*KPi,6.5*KPi);
  1.2857 +	test.Next(_L("sintest2"));
  1.2858 +    sintest2();
  1.2859 +	test.Next(_L("sintest3"));    
  1.2860 +	sintest3();
  1.2861 +	test.Next(_L("sintest4"));
  1.2862 +    sintest4();
  1.2863 +//	test.Next(_L("sintest5"));		// this test is no longer valid
  1.2864 +//	sintest5();
  1.2865 +
  1.2866 +	test.Next(_L("costest1"));
  1.2867 +	costest1();
  1.2868 +	test.Next(_L("costest2"));
  1.2869 +	costest2();
  1.2870 +	test.Next(_L("costest3"));
  1.2871 +	costest3();
  1.2872 +	test.Next(_L("costest4"));
  1.2873 +	costest4();
  1.2874 +//	test.Next(_L("costest5"));		// this test is no longer valid
  1.2875 +//	costest5();
  1.2876 +
  1.2877 +	test.Next(_L("tantest1(-.25*KPi,.25*KPi)"));                                            
  1.2878 +    tantest1(-.25*KPi,.25*KPi);
  1.2879 +	test.Next(_L("tantest1(.875*KPi,1.125*KPi)"));
  1.2880 +    tantest1(.875*KPi,1.125*KPi);
  1.2881 +	test.Next(_L("tantest1(6*KPi,6.25*KPi)"));
  1.2882 +    tantest1(6*KPi,6.25*KPi);
  1.2883 +	test.Next(_L("tantest2"));
  1.2884 +    tantest2();   
  1.2885 +	test.Next(_L("tantest3"));
  1.2886 +    tantest3();
  1.2887 +	test.Next(_L("tantest4"));
  1.2888 +    tantest4();
  1.2889 +//	test.Next(_L("tantest5"));		// this test is no longer valid
  1.2890 +//	tantest5();
  1.2891 +
  1.2892 +	test.Next(_L("astest1(-.125,0.125,15,0)"));
  1.2893 +    astest1(-.125,0.125,15,0);
  1.2894 +	test.Next(_L("astest1(-.125,0.125,15,1)"));
  1.2895 +    astest1(-.125,0.125,15,1);
  1.2896 +	test.Next(_L("astest2"));
  1.2897 +    astest2();
  1.2898 +	test.Next(_L("astest3"));
  1.2899 +    astest3();
  1.2900 +	test.Next(_L("astest4(0,1)"));
  1.2901 +    astest4(0,1);
  1.2902 +	test.Next(_L("astest4(1,1)"));
  1.2903 +    astest4(1,1);
  1.2904 +	test.Next(_L("astest4(1,-1)"));
  1.2905 +    astest4(1,-1);
  1.2906 +		  
  1.2907 +	test.Next(_L("attest1"));
  1.2908 +    attest1();
  1.2909 +	test.Next(_L("attest2"));
  1.2910 +    attest2();
  1.2911 +	test.Next(_L("attest3"));
  1.2912 +    attest3();
  1.2913 +	test.Next(_L("attest4"));
  1.2914 +    attest4();
  1.2915 +	test.Next(_L("attest5"));
  1.2916 +    attest5();
  1.2917 +
  1.2918 +    test.Next(_L("inttest1"));
  1.2919 +    inttest1();	
  1.2920 +	test.Next(_L("intitest2"));
  1.2921 +    inttest2();	
  1.2922 +	test.Next(_L("inttest3"));
  1.2923 +    inttest3();	
  1.2924 +	test.Next(_L("inttest4"));
  1.2925 +	inttest4();	
  1.2926 +
  1.2927 +	test.Next(_L("fractest1"));
  1.2928 +    fractest1();	
  1.2929 +	test.Next(_L("fractest2"));
  1.2930 +	fractest2();
  1.2931 +
  1.2932 +	test.Next(_L("modtest1"));
  1.2933 +    modtest1();
  1.2934 +	test.Next(_L("modtest2"));
  1.2935 +    modtest2();
  1.2936 +
  1.2937 +	test.Next(_L("Test duplicate parameters"));
  1.2938 +	DuplicateTest();
  1.2939 +
  1.2940 +	test.Next(_L("Test Math::Is...() functions"));
  1.2941 +	specialtest();
  1.2942 +
  1.2943 +	test.End();
  1.2944 +	return(KErrNone);
  1.2945 +    }
  1.2946 +