os/kernelhwsrv/kerneltest/e32test/math/t_i64.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32test\math\t_i64.cpp
sl@0
    15
// Tests TInt64
sl@0
    16
// Overview:
sl@0
    17
// Test 64-bit integer functionality.
sl@0
    18
// API Information:
sl@0
    19
// TInt64.
sl@0
    20
// Details:
sl@0
    21
// - Construct TInt64 with specified range of integer, real, high
sl@0
    22
// and low values and check constructor, copy constructor are as expected.
sl@0
    23
// - Test all the operators for range of values and check it is as expected.
sl@0
    24
// - Check the logical shift of specified number of bits is as expected.
sl@0
    25
// - Check multiplication of 64 bit integer by the specified 64 bit integer 
sl@0
    26
// using MulTop, fast multiplication of 64 bit integer by 10.
sl@0
    27
// - Verify the 64 bit integer divide and mod results are as expected.
sl@0
    28
// Platforms/Drives/Compatibility:
sl@0
    29
// All.
sl@0
    30
// Assumptions/Requirement/Pre-requisites:
sl@0
    31
// Failures and causes:
sl@0
    32
// Base Port information:
sl@0
    33
// 
sl@0
    34
//
sl@0
    35
sl@0
    36
#include <e32test.h>
sl@0
    37
#include <e32math.h>
sl@0
    38
sl@0
    39
inline TInt __i64multop(TInt64& aX, TInt64& aValue)
sl@0
    40
			{	Uint64 __lowResult; \
sl@0
    41
				Uint64 __highResult; \
sl@0
    42
				Math::UMul64(aX, aValue, __highResult, __lowResult); \
sl@0
    43
				aX = static_cast<TInt64>(__highResult); \
sl@0
    44
				return (__lowResult == UI64LIT(0x0000000000000000)) ?	-2 : \
sl@0
    45
				(__lowResult < UI64LIT(0x8000000000000000)) ?	-1 : \
sl@0
    46
				(__lowResult == UI64LIT(0x8000000000000000)) ?	0  : \
sl@0
    47
				/*__lowResult > UI64LIT(0x8000000000000000)*/	1; \
sl@0
    48
			}
sl@0
    49
sl@0
    50
#define	I64MULTOP(x, value) __i64multop(x, (value))
sl@0
    51
sl@0
    52
sl@0
    53
TInt HexMulAdd(TUint8 a1,TUint8 a2,TUint8& answer,TUint8& carry)
sl@0
    54
	{
sl@0
    55
	TUint x1= a1>'9' ? a1-'a'+10 : a1-'0';
sl@0
    56
	TUint x2= a2>'9' ? a2-'a'+10 : a2-'0';
sl@0
    57
	TUint a= answer>'9' ? answer-'a'+10 : answer-'0';
sl@0
    58
	TUint c= carry>'9' ? carry-'a'+10 : carry-'0';
sl@0
    59
	if (x1>15) return (KErrArgument);
sl@0
    60
	if (x2>15) return (KErrArgument);
sl@0
    61
	if (a>15) return (KErrArgument);
sl@0
    62
	if (c>15) return (KErrArgument);
sl@0
    63
	a+=(x1*x2)+c;
sl@0
    64
	c=a/16;
sl@0
    65
	a=a%16;
sl@0
    66
	a= a>9 ? a-10+'a' : a+'0';
sl@0
    67
	c= c>9 ? c-10+'a' : c+'0';
sl@0
    68
	answer=(TUint8)a;
sl@0
    69
	carry=(TUint8)c;
sl@0
    70
	return(KErrNone);
sl@0
    71
	}
sl@0
    72
sl@0
    73
TInt HexMul(TDesC8& a1,TDesC8& a2,TDes8& a3)
sl@0
    74
//
sl@0
    75
// Infinite precision hex multiplier
sl@0
    76
//
sl@0
    77
	{
sl@0
    78
	TInt l1=a1.Length();
sl@0
    79
	TInt l2=a2.Length();
sl@0
    80
	TInt l3=l1+l2;
sl@0
    81
	if (a3.MaxLength()<l3)
sl@0
    82
		return(KErrArgument);
sl@0
    83
	a3.Zero();
sl@0
    84
	TInt x;
sl@0
    85
	TInt y;
sl@0
    86
	TInt z;
sl@0
    87
	for (x=0;x<l3;x++)
sl@0
    88
		a3.Append('0');
sl@0
    89
	for (y=0;y<l2;y++)
sl@0
    90
		{
sl@0
    91
		TUint8 carry='0';
sl@0
    92
		for (z=0;z<l1;z++)
sl@0
    93
			{
sl@0
    94
			if(HexMulAdd(a2[l2-y-1],a1[l1-z-1],a3[l3-y-z-1],carry)!=KErrNone)
sl@0
    95
				return(KErrArgument);
sl@0
    96
			}
sl@0
    97
		if(HexMulAdd('0','0',a3[l3-y-l1-1],carry)!=KErrNone)
sl@0
    98
			return(KErrArgument);
sl@0
    99
		}
sl@0
   100
	return(KErrNone);
sl@0
   101
	}
sl@0
   102
sl@0
   103
sl@0
   104
LOCAL_D RTest test(_L("T_I64"));
sl@0
   105
sl@0
   106
LOCAL_C void SlowDivMod(const TInt64& aA, const TInt64& aB, TInt64& aDiv, TInt64& aMod)
sl@0
   107
//
sl@0
   108
//	Calculate Division/Remainder using repeated subtraction
sl@0
   109
//
sl@0
   110
	{
sl@0
   111
		TInt negative=0;
sl@0
   112
		TInt64 t=0;
sl@0
   113
sl@0
   114
		if (aA<0)
sl@0
   115
			{
sl@0
   116
			negative=1;
sl@0
   117
			aMod=-aA;
sl@0
   118
			}
sl@0
   119
		else
sl@0
   120
			{
sl@0
   121
			aMod=aA;
sl@0
   122
			}
sl@0
   123
		if (aB<0)
sl@0
   124
			{
sl@0
   125
			if (negative)
sl@0
   126
				negative=0;
sl@0
   127
			else
sl@0
   128
				negative=1;
sl@0
   129
			t=-aB;
sl@0
   130
			}
sl@0
   131
		else
sl@0
   132
			{
sl@0
   133
			t=aB;
sl@0
   134
			}
sl@0
   135
		aDiv=0;
sl@0
   136
sl@0
   137
		if ((t & UI64LIT(0xffffffff00000000)) == 0)
sl@0
   138
			{
sl@0
   139
			while (aMod >= (t << 31))
sl@0
   140
				{
sl@0
   141
				aDiv += static_cast<TUint32>(1 << 31);
sl@0
   142
				aMod -= t << 31;
sl@0
   143
				}
sl@0
   144
			}
sl@0
   145
		if ((t & UI64LIT(0xffffff0000000000)) == 0)
sl@0
   146
			{
sl@0
   147
			while (aMod >= (t << 23))
sl@0
   148
				{
sl@0
   149
				aDiv += 1 << 23;
sl@0
   150
				aMod -= t << 23;
sl@0
   151
				}
sl@0
   152
			}
sl@0
   153
		if ((t & UI64LIT(0xffff000000000000)) == 0)
sl@0
   154
			{
sl@0
   155
			while (aMod >= (t << 15))
sl@0
   156
				{
sl@0
   157
				aDiv += 1 << 15;
sl@0
   158
				aMod -= t << 15;
sl@0
   159
				}
sl@0
   160
			}
sl@0
   161
		if ((t & UI64LIT(0xff00000000000000)) == 0)
sl@0
   162
			{
sl@0
   163
			while (aMod >= (t << 7))
sl@0
   164
				{
sl@0
   165
				aDiv += 1 << 7;
sl@0
   166
				aMod -= t << 7;
sl@0
   167
				}
sl@0
   168
			}
sl@0
   169
		if ((t & UI64LIT(0xf000000000000000)) == 0)
sl@0
   170
			{
sl@0
   171
			while (aMod >= (t << 3))
sl@0
   172
				{
sl@0
   173
				aDiv += 1 << 3;
sl@0
   174
				aMod -= t << 3;
sl@0
   175
				}
sl@0
   176
			}
sl@0
   177
		while (aMod >= t)
sl@0
   178
			{
sl@0
   179
			++aDiv;
sl@0
   180
			aMod -= t;
sl@0
   181
			}
sl@0
   182
sl@0
   183
		if (negative)
sl@0
   184
			{
sl@0
   185
			aDiv=-aDiv;
sl@0
   186
			}
sl@0
   187
sl@0
   188
		if (aA < 0)
sl@0
   189
			{
sl@0
   190
			aMod =- aMod;	
sl@0
   191
			}
sl@0
   192
	}
sl@0
   193
sl@0
   194
LOCAL_C void DivModTest(const TInt64& aA, const TInt64& aB)
sl@0
   195
//
sl@0
   196
//	Test DivMod against SlowDivMod
sl@0
   197
//
sl@0
   198
	{
sl@0
   199
sl@0
   200
	if (aB!=0)
sl@0
   201
		{
sl@0
   202
		TInt64 n(aA),d(aB);
sl@0
   203
		TInt64 div=0,mod=0,res=0;
sl@0
   204
		
sl@0
   205
		SlowDivMod(n,d,div,mod);
sl@0
   206
		
sl@0
   207
		res = n % d;
sl@0
   208
		n /= d;
sl@0
   209
		
sl@0
   210
		test(n==div);
sl@0
   211
		test(res==mod);
sl@0
   212
		}
sl@0
   213
	}
sl@0
   214
sl@0
   215
sl@0
   216
LOCAL_C void Test1()
sl@0
   217
	{
sl@0
   218
	// Test the constructors
sl@0
   219
sl@0
   220
	// TInt64()
sl@0
   221
	test.Start(_L("Default constructor"));
sl@0
   222
	TInt64 t1;
sl@0
   223
	t1 = 0; // to prevent uninitialised warnings
sl@0
   224
	(void)(t1 > 0); // to prevent unused warnings
sl@0
   225
	
sl@0
   226
	// TInt64(TInt aVal)
sl@0
   227
	test.Next(_L("TInt64(TInt aVal)"));
sl@0
   228
	TInt64 t2(0);
sl@0
   229
	test(I64LOW(t2)==0 && I64HIGH(t2)==0);
sl@0
   230
	TInt64 t3(1);  	 
sl@0
   231
	test(I64LOW(t3)==1 && I64HIGH(t3)==0);
sl@0
   232
	TInt64 t4(KMaxTInt32);
sl@0
   233
	test(I64LOW(t4)==(TUint)KMaxTInt32 && I64HIGH(t4)==0);
sl@0
   234
	TInt64 t5(-1);
sl@0
   235
	test(I64INT(t5)==-1);
sl@0
   236
	test(I64LOW(t5)==KMaxTUint32 && I64HIGH(t5)==KMaxTUint32);
sl@0
   237
	TInt64 t6(KMinTInt32); 	
sl@0
   238
	test(I64INT(t6)==KMinTInt32);
sl@0
   239
sl@0
   240
	// TInt64(TUint aVal)
sl@0
   241
	test.Next(_L("TInt64(TUint aVal)"));
sl@0
   242
	TInt64 t7((TUint)0);
sl@0
   243
	test(I64LOW(t7)==0 && I64HIGH(t7)==0);
sl@0
   244
	TInt64 t8((TUint)1);  	 
sl@0
   245
	test(I64LOW(t8)==1 && I64HIGH(t8)==0);
sl@0
   246
	TInt64 t9(KMaxTUint32);
sl@0
   247
	test(I64LOW(t9)==KMaxTUint32 && I64HIGH(t9)==0);
sl@0
   248
sl@0
   249
	// TInt64(TUint aHigh,TUint aLow)
sl@0
   250
	test.Next(_L("TInt64(TUint aHigh,TUint aLow)"));
sl@0
   251
	TInt64 t10 = MAKE_TINT64(0,0);
sl@0
   252
	test(I64LOW(t10)==0 && I64HIGH(t10)==0);
sl@0
   253
	TInt64 t11 = MAKE_TINT64(KMaxTUint32,KMaxTUint32);   // highest value stored === (2**64)-1
sl@0
   254
	test(I64LOW(t11)==KMaxTUint32 && I64HIGH(t11)==KMaxTUint32);
sl@0
   255
sl@0
   256
	// TInt64(TReal aVal)
sl@0
   257
	test.Next(_L("TInt64(TReal aVal)"));
sl@0
   258
	TInt64 t12((TInt64)1.0);
sl@0
   259
	test(I64LOW(t12)==1 && I64HIGH(t12)==0);
sl@0
   260
	TInt64 t15((TInt64)4.99);
sl@0
   261
	test(I64LOW(t15)==4 && I64HIGH(t15)==0);
sl@0
   262
	
sl@0
   263
	TReal x;
sl@0
   264
	
sl@0
   265
	x = -9.223372036854776831e18; // -2^63 - 2^10 (to ensure rounding outside of TInt64 range)
sl@0
   266
	TInt64 t16((TInt64)x);
sl@0
   267
	test(t16==KMinTInt64);
sl@0
   268
	TInt64 t17((TInt64)0.5);
sl@0
   269
	test(I64LOW(t17)==0 && I64HIGH(t17)==0);
sl@0
   270
	TInt64 t18((TInt64)0.0);
sl@0
   271
	test(I64LOW(t18)==0 && I64HIGH(t18)==0);
sl@0
   272
	TInt64 t19((TInt64)-123325.23411412);
sl@0
   273
	test(I64LOW(t19)==(TUint)(-123325) && I64HIGH(t19)==0xffffffff);
sl@0
   274
	TInt64 t20((TInt64)1.0E-1);
sl@0
   275
	test(I64LOW(t20)==0 && I64HIGH(t20)==0);
sl@0
   276
	
sl@0
   277
	// Make variable volatile to protect ourselves from compiler optimisations. Given that the
sl@0
   278
	// following test is negative with unspecified results, we don't really care if we do not have
sl@0
   279
	// FPU/compiler parity.
sl@0
   280
	volatile TReal xout;
sl@0
   281
	xout = 9.223372036854776831e18; // 2^63 + 2^10 (to ensure rounding outside of TInt64 range)
sl@0
   282
	TInt64 t21((TInt64)xout);
sl@0
   283
sl@0
   284
	// IEEE 754 does not specify the value to be returned when a conversion
sl@0
   285
	// is performed on a value that is outside the range of the target, only
sl@0
   286
	// that an invalid operation exception be raised if the io fp exception
sl@0
   287
	// is not masked.
sl@0
   288
#if defined(__WINS__) || defined(__X86__)
sl@0
   289
	// The x86 FPU returns KMin... as the "indefinite number"
sl@0
   290
	test(t21 == KMinTInt64);
sl@0
   291
#else
sl@0
   292
	// The target compiler support libraries return KMax...
sl@0
   293
	test(t21 == KMaxTInt64);
sl@0
   294
#endif
sl@0
   295
sl@0
   296
	TReal limit=1048576.0*1048576.0*8192.0;		// integers <2^53 in modulus can be represented exactly
sl@0
   297
	TInt64 t22((TInt64)limit);
sl@0
   298
	test(I64LOW(t22)==0 && I64HIGH(t22)==0x00200000);
sl@0
   299
	TInt64 t23((TInt64)(limit-1.0));
sl@0
   300
	test(I64LOW(t23)==0xffffffff && I64HIGH(t23)==0x001fffff);
sl@0
   301
	TReal i64limit=limit*1024.0;				// 2^63
sl@0
   302
	// Make variable volatile to protect ourselves from compiler optimisations. Given that the
sl@0
   303
	// following test is negative with unspecified results, we don't really care if we do not have
sl@0
   304
	// FPU/compiler parity.
sl@0
   305
	volatile TReal i64limitout=i64limit;
sl@0
   306
	TInt64 t24((TInt64)i64limitout);
sl@0
   307
	
sl@0
   308
	// IEEE 754 does not specify the value to be returned when a conversion
sl@0
   309
	// is performed on a value that is outside the range of the target, only
sl@0
   310
	// that an invalid operation exception be raised if the io fp exception
sl@0
   311
	// is not masked.
sl@0
   312
#if defined(__WINS__) || defined(__X86__)
sl@0
   313
	// The x86 FPU returns KMin... as the "indefinite number"
sl@0
   314
	test(t24 == KMinTInt64);
sl@0
   315
#else
sl@0
   316
	// The target compiler support libraries return KMax...
sl@0
   317
	test(t24 == KMaxTInt64);
sl@0
   318
#endif
sl@0
   319
sl@0
   320
	TInt64 t25((TInt64)(i64limit-1024.0));
sl@0
   321
	test(I64LOW(t25)==0xfffffc00 && I64HIGH(t25)==0x7fffffff);
sl@0
   322
	TInt64 t26((TInt64)-i64limit);
sl@0
   323
	test(I64LOW(t26)==0x00000000 && I64HIGH(t26)==0x80000000);
sl@0
   324
	TInt64 t27((TInt64)(1024.0-i64limit));
sl@0
   325
	test(I64LOW(t27)==0x00000400 && I64HIGH(t27)==0x80000000);
sl@0
   326
sl@0
   327
sl@0
   328
	TInt i;
sl@0
   329
	TInt64 l;
sl@0
   330
	for (i=-99; i<100; i++)
sl@0
   331
		{
sl@0
   332
		x=1;
sl@0
   333
		l=1;
sl@0
   334
		TReal a(i);
sl@0
   335
		TInt64 b(i);
sl@0
   336
		while (Abs(x)<limit)
sl@0
   337
			{
sl@0
   338
//			test.Printf(_L("Testing %g\n"),x);
sl@0
   339
			TInt64 ll((TInt64)x);
sl@0
   340
			test(ll==l);
sl@0
   341
			ll=0;
sl@0
   342
			ll = (TInt64)x;
sl@0
   343
			test(ll==l);
sl@0
   344
			x*=a;
sl@0
   345
			l*=b;
sl@0
   346
			if (i==1 || i==0 || (i==-1 && l==TInt64(1)))
sl@0
   347
				break;
sl@0
   348
			}
sl@0
   349
		}
sl@0
   350
sl@0
   351
	// TInt64::GetTReal
sl@0
   352
	test.Next(_L("TInt64::GetTReal"));
sl@0
   353
sl@0
   354
	// GCC does optimise large portions of the test code out and there can be small
sl@0
   355
	// differences in the way GCC and the FPU round floating point values.
sl@0
   356
	// We isolate the following test by giving it its own variables. This should
sl@0
   357
	// prevent values returned by the FPU from being compared with wrong GCC calculations.
sl@0
   358
	TInt64 m = MAKE_TINT64(0x7fffffff,0xffffffff);
sl@0
   359
	TReal xy = I64REAL(m);
sl@0
   360
	TReal xx = 1048576.0*1048576.0*1048576.0*8.0 - 1.0; // 2^63 - 1
sl@0
   361
	test(xy == xx);
sl@0
   362
	//
sl@0
   363
sl@0
   364
	l = MAKE_TINT64(0x7fffffff,0xfffffc00);
sl@0
   365
	x = I64REAL(l);
sl@0
   366
sl@0
   367
	test(x == (i64limit - 1024.0));
sl@0
   368
sl@0
   369
	l = MAKE_TINT64(0x80000000,0x00000000);
sl@0
   370
	x = I64REAL(l);
sl@0
   371
sl@0
   372
	test(x == -i64limit);
sl@0
   373
sl@0
   374
	l = MAKE_TINT64(0x80000000,0x00000400);
sl@0
   375
	x = I64REAL(l);
sl@0
   376
sl@0
   377
	test(x == (1024.0 - i64limit));
sl@0
   378
sl@0
   379
	l = MAKE_TINT64(0x00000001,0x00000000);
sl@0
   380
	x = I64REAL(l);
sl@0
   381
sl@0
   382
	test(x == (65536.0 * 65536.0));
sl@0
   383
sl@0
   384
	l = MAKE_TINT64(0xffffffff,0x00000000);
sl@0
   385
	x = I64REAL(l);
sl@0
   386
sl@0
   387
	test(x == (-65536.0 * 65536.0));
sl@0
   388
sl@0
   389
	for (i=-99; i<100; i++)
sl@0
   390
		{
sl@0
   391
		x=1;
sl@0
   392
		l=1;
sl@0
   393
		TReal a(i);
sl@0
   394
		TInt64 b(i);
sl@0
   395
		while (Abs(x)<limit)
sl@0
   396
			{
sl@0
   397
//			test.Printf(_L("Testing %g\n"),x);
sl@0
   398
			TReal y = I64REAL(l);
sl@0
   399
			test(y==x);
sl@0
   400
			x*=a;
sl@0
   401
			l*=b;
sl@0
   402
			if (i==1 || i==0 || (i==-1 && l==TInt64(1)))
sl@0
   403
				break;
sl@0
   404
			}
sl@0
   405
		}
sl@0
   406
 
sl@0
   407
	// TInt64(const TInt64& aVal)
sl@0
   408
	test.Next(_L("Copy constructor"));
sl@0
   409
	TInt64 t13(t10);
sl@0
   410
	test(I64LOW(t13)==I64LOW(t10) && I64HIGH(t13)==I64HIGH(t10));
sl@0
   411
sl@0
   412
	test.Next(_L("Set"));
sl@0
   413
	t13 = MAKE_TINT64(0, 0);
sl@0
   414
	test(I64LOW(t13)==0 && I64HIGH(t13)==0);
sl@0
   415
	test.End();
sl@0
   416
	}
sl@0
   417
sl@0
   418
LOCAL_C void Test1_2()
sl@0
   419
//
sl@0
   420
//	Test Unary operators -, and +
sl@0
   421
//
sl@0
   422
	{
sl@0
   423
	TInt64 r(0),q(0);
sl@0
   424
sl@0
   425
	r=1;
sl@0
   426
	test(-r==-1);
sl@0
   427
	test(+r==1);
sl@0
   428
	r=-100;
sl@0
   429
	test(-r==100);
sl@0
   430
	test(+r==-100);
sl@0
   431
	r = MAKE_TINT64(540423,21344);
sl@0
   432
	test(-r==(q-r));
sl@0
   433
	test(+r==r);
sl@0
   434
	test(+r==MAKE_TINT64(540423,21344));
sl@0
   435
	r=0;
sl@0
   436
	test(-r==0);
sl@0
   437
	test(+r==0);
sl@0
   438
	}
sl@0
   439
sl@0
   440
sl@0
   441
LOCAL_C void Test2()
sl@0
   442
	{
sl@0
   443
	// Test the operators
sl@0
   444
sl@0
   445
	// =
sl@0
   446
	test.Start(_L("="));
sl@0
   447
	TInt64 r=0,r2=0, a = MAKE_TINT64(12345,54321);
sl@0
   448
	r=KMaxTInt32;
sl@0
   449
	test(I64LOW(r)==(TUint)KMaxTInt32 && I64HIGH(r)==0);
sl@0
   450
	r2=r=KMinTInt32;
sl@0
   451
	test(I64INT(r)==KMinTInt32);
sl@0
   452
	test(I64INT(r2)==KMinTInt32);
sl@0
   453
	r2=r=KMaxTUint32;
sl@0
   454
	test(I64LOW(r)==KMaxTUint32 && I64HIGH(r)==0);
sl@0
   455
	test(I64LOW(r2)==KMaxTUint32 && I64HIGH(r2)==0);
sl@0
   456
	r2=r=a;
sl@0
   457
	test(I64LOW(r)==I64LOW(a) && I64HIGH(r)==I64HIGH(a));
sl@0
   458
	test(I64LOW(r2)==I64LOW(a) && I64HIGH(r2)==I64HIGH(a));
sl@0
   459
sl@0
   460
	r2=r=(TInt64)((TReal)1.2);
sl@0
   461
	test(r==1);
sl@0
   462
	test(r2==1);
sl@0
   463
	r2=r=(TInt64)((TReal)20.9);
sl@0
   464
	test(r==20);
sl@0
   465
	test(r2==20);
sl@0
   466
	r2=r=(TInt64)((TReal)-100.2);
sl@0
   467
	test(r==-100);
sl@0
   468
	test(r2==-100);
sl@0
   469
	
sl@0
   470
sl@0
   471
sl@0
   472
	// +=, -=, *=, /=, %=, >>=, <<=, >>, <<
sl@0
   473
	// += 
sl@0
   474
	test.Next(_L("+="));
sl@0
   475
	r=-1;
sl@0
   476
	r+=1;
sl@0
   477
	test(I64INT(r)==0);
sl@0
   478
sl@0
   479
	r+=1;
sl@0
   480
	test(I64INT(r)==1);
sl@0
   481
sl@0
   482
	r=KMaxTUint32;
sl@0
   483
	r+=1;
sl@0
   484
	test(I64INT(r)-1==(TInt)KMaxTUint32);
sl@0
   485
sl@0
   486
	r=KMinTInt32;
sl@0
   487
	r+=1;
sl@0
   488
	test(I64INT(r)==KMinTInt32+1);
sl@0
   489
sl@0
   490
	r=0;
sl@0
   491
	r+=MAKE_TINT64(0,0x80000000u);
sl@0
   492
	test(r==MAKE_TINT64(0,0x80000000u));
sl@0
   493
sl@0
   494
	// -=
sl@0
   495
	test.Next(_L("-="));						 
sl@0
   496
	r=-1;
sl@0
   497
	r-=1;
sl@0
   498
	test(I64INT(r)==-2);
sl@0
   499
	r=0;
sl@0
   500
	r-=1;
sl@0
   501
	test(I64INT(r)==-1);
sl@0
   502
	r=1;
sl@0
   503
	r-=1;
sl@0
   504
	test(I64INT(r)==0);
sl@0
   505
	r=KMaxTUint32;
sl@0
   506
	r+=1;
sl@0
   507
	r-=1;
sl@0
   508
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32);
sl@0
   509
	test(I64INT(r)==(TInt)KMaxTUint32);
sl@0
   510
	r-=1;
sl@0
   511
	test(I64INT(r)==(TInt)(KMaxTUint32-1));
sl@0
   512
sl@0
   513
sl@0
   514
	// *= 
sl@0
   515
	test.Next(_L("*="));
sl@0
   516
	r=KMaxTUint32;			// ffffffff * 2 = 1 fffffffe
sl@0
   517
	r*=2;
sl@0
   518
	test(I64HIGH(r)==1 && I64LOW(r)==KMaxTUint32-1);
sl@0
   519
sl@0
   520
	r=KMaxTUint32-1;
sl@0
   521
	r*=2;
sl@0
   522
	r+=2;
sl@0
   523
	test(I64HIGH(r)==1 && I64LOW(r)==KMaxTUint32-1);
sl@0
   524
sl@0
   525
	r=KMaxTUint32;
sl@0
   526
	r+=1;
sl@0
   527
	r*=2;
sl@0
   528
	test(I64HIGH(r)==2 && I64LOW(r)==0);
sl@0
   529
sl@0
   530
	TUint PosMinTInt=(TUint)KMinTInt32;
sl@0
   531
	r=PosMinTInt;
sl@0
   532
	r*=-1;
sl@0
   533
	test(I64INT(r)==KMinTInt32);
sl@0
   534
sl@0
   535
	r=KMinTInt32;
sl@0
   536
	r*=-1;
sl@0
   537
	r-=1;
sl@0
   538
	test(I64INT(r)==KMaxTInt32);
sl@0
   539
sl@0
   540
	r=KMaxTUint32;	   	// ffffffff * ffffffff + (2 * ffffffff) = ffffffff ffffffff
sl@0
   541
	r*=KMaxTUint32;
sl@0
   542
	r+=KMaxTUint32;
sl@0
   543
	r+=KMaxTUint32;
sl@0
   544
	test(I64LOW(r)==KMaxTUint32 && I64HIGH(r)==KMaxTUint32);
sl@0
   545
sl@0
   546
	r=KMaxTUint32;
sl@0
   547
	r+=1;
sl@0
   548
	r*=2;
sl@0
   549
	test(I64LOW(r)==0 && I64HIGH(r)==2);
sl@0
   550
sl@0
   551
sl@0
   552
	// /=
sl@0
   553
	test.Next(_L("/="));
sl@0
   554
	r=4;
sl@0
   555
	r/=2;
sl@0
   556
	test(I64INT(r)==2);
sl@0
   557
	r=4;
sl@0
   558
	r/=-2;
sl@0
   559
	test(I64INT(r)==-2);
sl@0
   560
	r=-4;
sl@0
   561
	r/=1;
sl@0
   562
	test(I64INT(r)==-4);
sl@0
   563
	r=-8;
sl@0
   564
sl@0
   565
	r/=-2;
sl@0
   566
	test(I64INT(r)==4);
sl@0
   567
	r=4;
sl@0
   568
sl@0
   569
	r/=4;
sl@0
   570
	test(I64INT(r)==1);
sl@0
   571
	r=0;
sl@0
   572
sl@0
   573
	r/=4;
sl@0
   574
	test(I64INT(r)==0);
sl@0
   575
	r=KMaxTUint32;
sl@0
   576
	TInt64 z(KMaxTUint32);
sl@0
   577
	r/=z;
sl@0
   578
	test(I64INT(r)==1);
sl@0
   579
	r=KMinTInt32;
sl@0
   580
	z=KMinTInt32;
sl@0
   581
	r/=z;
sl@0
   582
	test(I64INT(r)==1);
sl@0
   583
	r=KMinTInt32;
sl@0
   584
	z = MAKE_TINT64(0,(TUint)KMinTInt32);
sl@0
   585
	r/=z;
sl@0
   586
	test(I64INT(r)==-1);
sl@0
   587
	r=KMaxTUint32;			
sl@0
   588
	r*=2;
sl@0
   589
	r/=2;
sl@0
   590
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32);
sl@0
   591
   	r=KMaxTUint32;
sl@0
   592
	a=KMaxTUint32;
sl@0
   593
	r*=z;
sl@0
   594
	r/=z;
sl@0
   595
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32);
sl@0
   596
	r = MAKE_TINT64(0,(TUint)KMinTInt32);
sl@0
   597
	r/=-1;
sl@0
   598
	test(I64LOW(r)==(TUint)KMinTInt32);
sl@0
   599
	r=0;
sl@0
   600
	r/=KMaxTUint32;
sl@0
   601
	test(I64INT(r)==0);
sl@0
   602
	r=0;
sl@0
   603
	r/=KMinTInt32;
sl@0
   604
	test(I64INT(r)==0);
sl@0
   605
	r=0;
sl@0
   606
	TInt64 b = MAKE_TINT64(KMaxTUint32,KMaxTUint32);
sl@0
   607
	r/=b;
sl@0
   608
	test(I64INT(r)==0);
sl@0
   609
	TInt64 c = MAKE_TINT64(KMaxTUint32,KMaxTUint32);	  // -1/Anything == 0
sl@0
   610
	TInt64* cptr = &c;		// MSVC compiler calculates -1/anything at compile time
sl@0
   611
	*cptr /= KMaxTUint32;	// and gets it wrong if we don't use a pointer, bizarre.
sl@0
   612
	test(I64LOW(c)==0 && I64HIGH(c)==0);
sl@0
   613
	r=-1;
sl@0
   614
	z=1;
sl@0
   615
	r/=z;
sl@0
   616
	test(r==-1);
sl@0
   617
	r=-r;
sl@0
   618
	r/=z;
sl@0
   619
	test(r==1);
sl@0
   620
	r = MAKE_TINT64(0x01,KMaxTUint32);
sl@0
   621
	z=2;
sl@0
   622
	r/=z;
sl@0
   623
	test(r==TInt64(KMaxTUint32));
sl@0
   624
	r = MAKE_TINT64(0x01,KMaxTUint32);
sl@0
   625
	z = MAKE_TINT64(0,KMaxTUint32);
sl@0
   626
	r/=z;
sl@0
   627
	test(r==TInt64(2));
sl@0
   628
	r = MAKE_TINT64(1,0);
sl@0
   629
	r/=z;
sl@0
   630
	test(r==TInt64(1));
sl@0
   631
	r = MAKE_TINT64(6221,5621243);
sl@0
   632
	z = MAKE_TINT64(3,42011);
sl@0
   633
	r/=z;
sl@0
   634
	test(r==2073);
sl@0
   635
	r=100;
sl@0
   636
	z=99;
sl@0
   637
	r/=z;
sl@0
   638
	test(r==1);
sl@0
   639
	r = MAKE_TINT64(17,KMaxTUint32);
sl@0
   640
	z = MAKE_TINT64(0,8);
sl@0
   641
	test((r/=z)==MAKE_TINT64(0x2, 0x3fffffff));
sl@0
   642
sl@0
   643
	// %=
sl@0
   644
	test.Next(_L("%="));
sl@0
   645
	r=4;
sl@0
   646
	r%=4;
sl@0
   647
	test(I64INT(r)==0);
sl@0
   648
	r=4;
sl@0
   649
	r%=1;
sl@0
   650
	test(I64INT(r)==0);
sl@0
   651
	r=5;
sl@0
   652
	r%=3;
sl@0
   653
	test(I64INT(r)==2);
sl@0
   654
	r=(-5);
sl@0
   655
	r%=3;
sl@0
   656
	test(I64INT(r)==(-2));
sl@0
   657
	r = MAKE_TINT64(134,KMaxTUint32-10342);
sl@0
   658
	z = MAKE_TINT64(134,0);
sl@0
   659
	test((r%=z)==KMaxTUint32-10342);
sl@0
   660
	r = MAKE_TINT64(134,KMaxTUint32-10342);
sl@0
   661
	z = MAKE_TINT64(134,KMaxTUint32-10343);
sl@0
   662
	test((r%=z)==1);
sl@0
   663
	r = MAKE_TINT64(1363,0xfd432ab0u);
sl@0
   664
	z = MAKE_TINT64(0,16);
sl@0
   665
	test((r%=z)==0);
sl@0
   666
	
sl@0
   667
	r=-10;
sl@0
   668
	r%=3;
sl@0
   669
	test(r==-1);
sl@0
   670
	r=-10;
sl@0
   671
	r%=-3;
sl@0
   672
	test(r==-1);
sl@0
   673
	r=10;
sl@0
   674
	r%=3;
sl@0
   675
	test(r==1);
sl@0
   676
	r=10;
sl@0
   677
	r%=-3;
sl@0
   678
	test(r==1);
sl@0
   679
sl@0
   680
	// <<= and >>=
sl@0
   681
	// <<=
sl@0
   682
	test.Next(_L("<<="));
sl@0
   683
	r=1;
sl@0
   684
	r<<=32;
sl@0
   685
	test(I64LOW(r)==0 && I64HIGH(r)==1);
sl@0
   686
	r<<=31;
sl@0
   687
	test(I64LOW(r)==0 && I64HIGH(r)==0x80000000);
sl@0
   688
sl@0
   689
	r=1;
sl@0
   690
	r<<=31;
sl@0
   691
	test(I64LOW(r)==0x80000000 && I64HIGH(r)==0);
sl@0
   692
	r<<=32;
sl@0
   693
	test(I64LOW(r)==0 && I64HIGH(r)==0x80000000);
sl@0
   694
sl@0
   695
	r=1;
sl@0
   696
	r<<=63;
sl@0
   697
	test(I64LOW(r)==0 && I64HIGH(r)==0x80000000);
sl@0
   698
sl@0
   699
	r=0;
sl@0
   700
	r<<=32;
sl@0
   701
	test(I64LOW(r)==0 && I64HIGH(r)==0);
sl@0
   702
sl@0
   703
	r=0xC0000000; 	// 1100000..........
sl@0
   704
	r<<=1;
sl@0
   705
	test(I64HIGH(r)==1 && I64LOW(r)==0x80000000);	// 100000.......
sl@0
   706
	r<<=1;
sl@0
   707
	test(I64HIGH(r)==3 && I64LOW(r)==0);
sl@0
   708
	r<<=1;
sl@0
   709
	test(I64HIGH(r)==6 && I64LOW(r)==0);
sl@0
   710
sl@0
   711
	r = MAKE_TINT64(0,KMaxTUint32);
sl@0
   712
	r<<=32;
sl@0
   713
	test(I64LOW(r)==0 && I64HIGH(r)==KMaxTUint32);
sl@0
   714
sl@0
   715
	// >>=
sl@0
   716
	test.Next(_L(">>="));
sl@0
   717
	r = MAKE_TINT64(3,0);
sl@0
   718
	r>>=1;
sl@0
   719
	test(I64HIGH(r)==1 && I64LOW(r)==0x80000000);
sl@0
   720
	r>>=1;
sl@0
   721
	test(I64HIGH(r)==0 && I64LOW(r)==0xC0000000);
sl@0
   722
sl@0
   723
	r = MAKE_TINT64(0x80000000,0);  
sl@0
   724
	r>>=(31);
sl@0
   725
	test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==0);
sl@0
   726
	r>>=(32);
sl@0
   727
	test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==KMaxTUint32);
sl@0
   728
sl@0
   729
	r = MAKE_TINT64(0x80000000,0);
sl@0
   730
	r>>=(32);
sl@0
   731
	test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==0x80000000);
sl@0
   732
sl@0
   733
	r = MAKE_TINT64(0x80000000,0);
sl@0
   734
	r>>=63;
sl@0
   735
	test(I64LOW(r)==KMaxTUint32 && I64HIGH(r)==KMaxTUint32);
sl@0
   736
sl@0
   737
	r = MAKE_TINT64(KMaxTUint32, 0);
sl@0
   738
	r>>=32;
sl@0
   739
	test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==KMaxTUint32);
sl@0
   740
sl@0
   741
	// <<
sl@0
   742
	test.Next(_L("<<"));
sl@0
   743
	r=1;
sl@0
   744
	TInt64 t = r<<32;
sl@0
   745
	test(I64LOW(t)==0 && I64HIGH(t)==1);
sl@0
   746
	t = t<<31;
sl@0
   747
	test(I64LOW(t)==0 && I64HIGH(t)==0x80000000);
sl@0
   748
sl@0
   749
	r=1;
sl@0
   750
	t = r<<31;
sl@0
   751
	test(I64LOW(t)==0x80000000 && I64HIGH(t)==0);
sl@0
   752
	t = t<<32;
sl@0
   753
	test(I64LOW(t)==0 && I64HIGH(t)==0x80000000);
sl@0
   754
sl@0
   755
	r=1;
sl@0
   756
	t = r<<63;
sl@0
   757
	test(I64LOW(t)==0 && I64HIGH(t)==0x80000000);
sl@0
   758
sl@0
   759
	r=0;
sl@0
   760
	t = r<<32;
sl@0
   761
	test(I64LOW(t)==0 && I64HIGH(t)==0);
sl@0
   762
sl@0
   763
	r=0xC0000000; 	// 1100000..........
sl@0
   764
	t = r<<1;
sl@0
   765
	test(I64HIGH(t)==1 && I64LOW(t)==0x80000000);	// 100000.......
sl@0
   766
	t = t<<1;
sl@0
   767
	test(I64HIGH(t)==3 && I64LOW(t)==0);
sl@0
   768
	t = t<<1;
sl@0
   769
	test(I64HIGH(t)==6 && I64LOW(t)==0);
sl@0
   770
sl@0
   771
	r = MAKE_TINT64(0,KMaxTUint32);
sl@0
   772
	t = r<<32;
sl@0
   773
	test(I64LOW(t)==0 && I64HIGH(t)==KMaxTUint32);
sl@0
   774
sl@0
   775
	// >>
sl@0
   776
	test.Next(_L(">>"));
sl@0
   777
	r = MAKE_TINT64(3,0);
sl@0
   778
	t = r>>1;
sl@0
   779
	test(I64HIGH(t)==1 && I64LOW(t)==0x80000000);
sl@0
   780
	t = t>>1;
sl@0
   781
	test(I64HIGH(t)==0 && I64LOW(t)==0xC0000000);
sl@0
   782
sl@0
   783
	r = MAKE_TINT64(0x80000000,0);  
sl@0
   784
	t = r>>(31);
sl@0
   785
	test(I64HIGH(t)==KMaxTUint32 && I64LOW(t)==0);
sl@0
   786
	t = t>>(32);
sl@0
   787
	test(I64HIGH(t)==KMaxTUint32 && I64LOW(t)==KMaxTUint32);
sl@0
   788
	t = t>>1;
sl@0
   789
	test(I64HIGH(t)==KMaxTUint32 && I64LOW(t)==KMaxTUint32);
sl@0
   790
	t = t>>16;
sl@0
   791
	test(I64HIGH(t)==KMaxTUint32 && I64LOW(t)==KMaxTUint32);
sl@0
   792
sl@0
   793
	r = MAKE_TINT64(0x80000000,0);
sl@0
   794
	t = r>>(32);
sl@0
   795
	test(I64HIGH(t)==KMaxTUint32 && I64LOW(t)==0x80000000);
sl@0
   796
sl@0
   797
	r = MAKE_TINT64(0x80000000,0);
sl@0
   798
	t = r>>63;
sl@0
   799
	test(I64LOW(t)==KMaxTUint32 && I64HIGH(t)==KMaxTUint32);
sl@0
   800
sl@0
   801
	r = MAKE_TINT64(KMaxTUint32, 0);
sl@0
   802
	t = r>>32;
sl@0
   803
	test(I64HIGH(t)==KMaxTUint32 && I64LOW(t)==KMaxTUint32);
sl@0
   804
sl@0
   805
	r = MAKE_TINT64(0x40000000,0);
sl@0
   806
	t = r>>30;
sl@0
   807
	test(I64HIGH(t)==1 && I64LOW(t)==0);
sl@0
   808
	t = r>>31;
sl@0
   809
	test(I64HIGH(t)==0 && I64LOW(t)==0x80000000);
sl@0
   810
	t = r>>62;
sl@0
   811
	test(I64HIGH(t)==0 && I64LOW(t)==1);
sl@0
   812
	t = r>>63;
sl@0
   813
	test(I64HIGH(t)==0 && I64LOW(t)==0);
sl@0
   814
sl@0
   815
	test.End();
sl@0
   816
	}
sl@0
   817
sl@0
   818
LOCAL_C void Test3()
sl@0
   819
	{
sl@0
   820
	// Test some more operators
sl@0
   821
sl@0
   822
	// unary -
sl@0
   823
	test.Start(_L("unary -"));
sl@0
   824
	TInt64 r=0, x(KMinTInt32);
sl@0
   825
	r=-x;
sl@0
   826
	test(I64INT(r)==KMinTInt32);
sl@0
   827
sl@0
   828
	x = MAKE_TINT64(0,0x80000000);
sl@0
   829
	r=-x;
sl@0
   830
	test(I64INT(r)==KMinTInt32);
sl@0
   831
sl@0
   832
	// ++
sl@0
   833
	// post increment
sl@0
   834
	test.Next(_L("++"));
sl@0
   835
	x=-1;
sl@0
   836
	r=x++;
sl@0
   837
	test(I64INT(r)==-1 && I64INT(x)==0);
sl@0
   838
	r=x++;
sl@0
   839
	test(I64INT(r)==0 && I64INT(x)==1);
sl@0
   840
	r=x++;
sl@0
   841
	test(I64INT(r)==1 && I64INT(x)==2);
sl@0
   842
sl@0
   843
	x=KMinTInt32;
sl@0
   844
	r=x++;
sl@0
   845
	test(I64INT(r)==KMinTInt32 && I64INT(x)==KMinTInt32+1);
sl@0
   846
sl@0
   847
	x=KMaxTUint32;
sl@0
   848
	r=x++;
sl@0
   849
	test(I64INT(r)==(TInt)KMaxTUint32 && I64HIGH(x)==1 && I64LOW(x)==0);
sl@0
   850
	r=x++;
sl@0
   851
	test(I64HIGH(r)==1 && I64LOW(r)==0 && I64HIGH(x)==1 && I64LOW(x)==1);
sl@0
   852
sl@0
   853
	// pre increment;
sl@0
   854
	x=-1;
sl@0
   855
	r=++x;
sl@0
   856
	test(I64INT(r)==0 && I64INT(x)==0);
sl@0
   857
	r=++x;
sl@0
   858
	test(I64INT(r)==1 && I64INT(x)==1);
sl@0
   859
	r=++x;
sl@0
   860
	test(I64INT(r)==2 && I64INT(x)==2);
sl@0
   861
sl@0
   862
	x=KMinTInt32;
sl@0
   863
	r=++x;
sl@0
   864
	test(I64INT(r)==KMinTInt32+1 && I64INT(x)==KMinTInt32+1);
sl@0
   865
sl@0
   866
	x=KMaxTUint32;
sl@0
   867
	r=++x;
sl@0
   868
	test(I64HIGH(r) && I64HIGH(x)==1 && I64LOW(x)==0);
sl@0
   869
	r=x++;
sl@0
   870
	test(I64HIGH(r)==1 && I64LOW(r)==0 && I64HIGH(x)==1 && I64LOW(x)==1);
sl@0
   871
sl@0
   872
	
sl@0
   873
	// --
sl@0
   874
	test.Next(_L("--"));
sl@0
   875
	// post decrement	   
sl@0
   876
	x=1;
sl@0
   877
	r=x--;
sl@0
   878
	test(I64INT(r)==1 && I64INT(x)==0);
sl@0
   879
	r=x--;
sl@0
   880
	test(I64INT(r)==0 && I64INT(x)==-1);
sl@0
   881
	r=x--;
sl@0
   882
	test(I64INT(r)==-1 && I64INT(x)==-2);
sl@0
   883
sl@0
   884
	x=KMinTInt32+1;
sl@0
   885
	r=x--;
sl@0
   886
	test(I64INT(r)==KMinTInt32+1 && I64INT(x)==KMinTInt32);
sl@0
   887
sl@0
   888
	x=KMaxTUint32;
sl@0
   889
	x+=1;
sl@0
   890
	r=x--;
sl@0
   891
	test(I64HIGH(r)==1 && I64LOW(r)==0 && I64HIGH(x)==0 && I64LOW(x)==KMaxTUint32);
sl@0
   892
	r=x--;
sl@0
   893
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32 && I64HIGH(x)==0 && I64LOW(x)==KMaxTUint32-1);
sl@0
   894
sl@0
   895
	x = MAKE_TINT64(KMaxTUint32,KMaxTUint32);
sl@0
   896
	r=x--;
sl@0
   897
	test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==KMaxTUint32 && I64HIGH(x)==KMaxTUint32 && I64LOW(x)==KMaxTUint32-1);
sl@0
   898
sl@0
   899
	// pre decrement	   
sl@0
   900
	x=1;
sl@0
   901
	r=--x;
sl@0
   902
	test(I64INT(r)==0 && I64INT(x)==0);
sl@0
   903
	r=--x;
sl@0
   904
	test(I64INT(r)==-1 && I64INT(x)==-1);
sl@0
   905
	r=--x;
sl@0
   906
	test(I64INT(r)==-2 && I64INT(x)==-2);
sl@0
   907
sl@0
   908
	x=KMinTInt32+1;
sl@0
   909
	r=--x;
sl@0
   910
	test(I64INT(r)==KMinTInt32 && I64INT(x)==KMinTInt32);
sl@0
   911
sl@0
   912
	x=KMaxTUint32;
sl@0
   913
	x+=1;
sl@0
   914
	r=--x;
sl@0
   915
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32 && I64HIGH(x)==0 && I64LOW(x)==KMaxTUint32);
sl@0
   916
	r=--x;
sl@0
   917
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32-1 && I64HIGH(x)==0 && I64LOW(x)==KMaxTUint32-1);
sl@0
   918
sl@0
   919
	x = MAKE_TINT64(KMaxTUint32,KMaxTUint32);
sl@0
   920
	r=--x;
sl@0
   921
	test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==KMaxTUint32-1 && I64HIGH(x)==KMaxTUint32 && I64LOW(x)==KMaxTUint32-1);
sl@0
   922
sl@0
   923
  
sl@0
   924
sl@0
   925
	// Binary +
sl@0
   926
	test.Next(_L("Binary +"));
sl@0
   927
	x=KMinTInt32;
sl@0
   928
	r=x+1;
sl@0
   929
	test(I64INT(r)==KMinTInt32+1 && I64INT(x)==KMinTInt32);
sl@0
   930
sl@0
   931
	x=-1;
sl@0
   932
	r=x+1;
sl@0
   933
	test(I64INT(r)==0 && I64INT(x)==-1);
sl@0
   934
	x=r+1;
sl@0
   935
	test(I64INT(r)==0 && I64INT(x)==1);
sl@0
   936
sl@0
   937
	x=KMaxTUint32;
sl@0
   938
	r=x+KMaxTUint32;
sl@0
   939
	test(I64HIGH(r)==1 && I64LOW(r)==KMaxTUint-1);
sl@0
   940
sl@0
   941
	x=KMaxTUint32;
sl@0
   942
	x+=1;
sl@0
   943
	r=x+(-1);
sl@0
   944
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32);
sl@0
   945
sl@0
   946
	TInt64 y(0);
sl@0
   947
	x=KMaxTUint32;
sl@0
   948
	r=x+y;
sl@0
   949
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32);
sl@0
   950
sl@0
   951
	y=KMaxTUint32;
sl@0
   952
	r=x+y;
sl@0
   953
	test(I64HIGH(r)==1 && I64LOW(r)==KMaxTUint32-1);
sl@0
   954
sl@0
   955
	y=0;
sl@0
   956
	x = MAKE_TINT64(KMaxTUint32,KMaxTUint32);
sl@0
   957
	r=x+y;
sl@0
   958
	test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==KMaxTUint32);
sl@0
   959
sl@0
   960
	y=1;
sl@0
   961
	x = MAKE_TINT64(KMaxTUint32,KMaxTUint32);
sl@0
   962
	x-=1;
sl@0
   963
	r=x+y;
sl@0
   964
	test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==KMaxTUint32);
sl@0
   965
sl@0
   966
	y=0;
sl@0
   967
	x=KMinTInt32;
sl@0
   968
	r=x+y;
sl@0
   969
	test(I64INT(r)==KMinTInt32);
sl@0
   970
sl@0
   971
	y=-1;
sl@0
   972
	x=KMinTInt32;
sl@0
   973
	x+=1;
sl@0
   974
	r=x+y;
sl@0
   975
	test(I64INT(r)==KMinTInt32);
sl@0
   976
	
sl@0
   977
	y=-1;
sl@0
   978
	x=-1;
sl@0
   979
	r=x+y;
sl@0
   980
	test(I64INT(r)==-2);
sl@0
   981
sl@0
   982
	y=-1;
sl@0
   983
	x=KMaxTUint32;
sl@0
   984
	r=x+y;
sl@0
   985
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32-1);
sl@0
   986
	y=-1;
sl@0
   987
	x+=1;
sl@0
   988
	r=x+y;
sl@0
   989
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32);
sl@0
   990
	y=-1;
sl@0
   991
	x = MAKE_TINT64(KMaxTUint32,KMaxTUint32);
sl@0
   992
	r=x+y;
sl@0
   993
	test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==KMaxTUint32-1);
sl@0
   994
sl@0
   995
	y=KMinTInt32;
sl@0
   996
	x=KMaxTUint32;
sl@0
   997
	r=x+y;
sl@0
   998
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32-(TUint)KMinTInt32);
sl@0
   999
	x = MAKE_TINT64(KMaxTUint32,KMaxTUint32);
sl@0
  1000
	r=x+y;
sl@0
  1001
	test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==0x7fffffff);
sl@0
  1002
sl@0
  1003
	y=KMinTInt32;
sl@0
  1004
	x=-(KMinTInt32+1);
sl@0
  1005
	x+=1;
sl@0
  1006
	r=x+y;
sl@0
  1007
	test(I64INT(r)==0);
sl@0
  1008
sl@0
  1009
sl@0
  1010
	// Binary -
sl@0
  1011
	test.Next(_L("Binary -"));
sl@0
  1012
	x=KMinTInt32+1;
sl@0
  1013
	r=x-1;
sl@0
  1014
	test(I64INT(r)==KMinTInt32);
sl@0
  1015
sl@0
  1016
	x=2;
sl@0
  1017
	r=x-1;
sl@0
  1018
	test(I64INT(r)==1);
sl@0
  1019
	x=1;
sl@0
  1020
	r=x-1;
sl@0
  1021
	test(I64INT(r)==0);
sl@0
  1022
	x=0;
sl@0
  1023
	r=x-1;
sl@0
  1024
	test(I64INT(r)==-1);
sl@0
  1025
sl@0
  1026
	x=KMaxTUint32;
sl@0
  1027
	r=x-KMaxTUint32;
sl@0
  1028
	test(I64INT(r)==0);
sl@0
  1029
sl@0
  1030
	x=KMaxTUint32;
sl@0
  1031
	x+=1;
sl@0
  1032
	r=x-1;
sl@0
  1033
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32);
sl@0
  1034
sl@0
  1035
	x=KMaxTUint32;
sl@0
  1036
	r=x-1;
sl@0
  1037
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32-1);
sl@0
  1038
sl@0
  1039
	x = MAKE_TINT64(KMaxTUint32,KMaxTUint32);
sl@0
  1040
	r=x-1;
sl@0
  1041
	test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==KMaxTUint32-1);
sl@0
  1042
sl@0
  1043
sl@0
  1044
	y=0;
sl@0
  1045
	x=KMaxTUint32;
sl@0
  1046
	r=x-y;
sl@0
  1047
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32);
sl@0
  1048
sl@0
  1049
	y=KMaxTUint32;
sl@0
  1050
	r=x-y;
sl@0
  1051
	test(I64INT(r)==0);
sl@0
  1052
sl@0
  1053
	x=KMaxTUint32;
sl@0
  1054
	x+=1;
sl@0
  1055
	y=1;
sl@0
  1056
	r=x-1;
sl@0
  1057
   	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32);
sl@0
  1058
	x-=1;
sl@0
  1059
	r=x-1;
sl@0
  1060
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32-1);
sl@0
  1061
sl@0
  1062
	y=0;
sl@0
  1063
	x = MAKE_TINT64(KMaxTUint32,KMaxTUint32);
sl@0
  1064
	r=x-y;
sl@0
  1065
	test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==KMaxTUint32);
sl@0
  1066
sl@0
  1067
	y=1;
sl@0
  1068
	x = MAKE_TINT64(KMaxTUint32,KMaxTUint32);
sl@0
  1069
	r=x-y;
sl@0
  1070
	test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==KMaxTUint32-1);
sl@0
  1071
sl@0
  1072
	y=0;
sl@0
  1073
	x=KMinTInt32;
sl@0
  1074
	r=x-y;
sl@0
  1075
	test(I64INT(r)==KMinTInt32);
sl@0
  1076
sl@0
  1077
	y=1;
sl@0
  1078
	x=KMinTInt32;
sl@0
  1079
	x+=1;
sl@0
  1080
	r=x-y;
sl@0
  1081
	test(I64INT(r)==KMinTInt32);
sl@0
  1082
	
sl@0
  1083
	y=1;
sl@0
  1084
	x=1;
sl@0
  1085
	r=x-y;
sl@0
  1086
	test(I64INT(r)==0);
sl@0
  1087
sl@0
  1088
	y=-1;
sl@0
  1089
	x=-1;
sl@0
  1090
	r=x-y;
sl@0
  1091
	test(I64INT(r)==0);
sl@0
  1092
sl@0
  1093
	x=0;
sl@0
  1094
	y=KMinTInt32;
sl@0
  1095
	r=x-y;
sl@0
  1096
	test(I64INT(r)==KMinTInt32);
sl@0
  1097
sl@0
  1098
	x=KMinTInt32;
sl@0
  1099
	y=KMinTInt32;
sl@0
  1100
	r=x-y;
sl@0
  1101
	test(I64INT(r)==0);
sl@0
  1102
sl@0
  1103
	test.End();
sl@0
  1104
	}
sl@0
  1105
sl@0
  1106
sl@0
  1107
LOCAL_C void Test4()
sl@0
  1108
// still more operators
sl@0
  1109
	{
sl@0
  1110
	// * 
sl@0
  1111
	test.Start(_L("Binary *"));
sl@0
  1112
	TInt64 r(0), x(1), y(0);
sl@0
  1113
	r=x*y;
sl@0
  1114
	test(I64INT(r)==0);
sl@0
  1115
sl@0
  1116
	y=-1;
sl@0
  1117
	r=x*y;
sl@0
  1118
	test(I64INT(r)==-1);
sl@0
  1119
sl@0
  1120
	x=-1;
sl@0
  1121
	r=x*y;
sl@0
  1122
	test(I64INT(r)==1);
sl@0
  1123
sl@0
  1124
	x=KMinTInt32;
sl@0
  1125
	r=x*y;
sl@0
  1126
	test(I64INT(r)==KMinTInt32);
sl@0
  1127
sl@0
  1128
	y=0;
sl@0
  1129
	r=x*y;
sl@0
  1130
	test(I64INT(r)==0);
sl@0
  1131
sl@0
  1132
	y=KMinTInt32;
sl@0
  1133
	r=x*y;
sl@0
  1134
	test(I64LOW(r)==0 && I64HIGH(r)==0x40000000);
sl@0
  1135
sl@0
  1136
	y=KMaxTUint32;
sl@0
  1137
	x=KMaxTUint32;
sl@0
  1138
	r=x*y;
sl@0
  1139
	test(I64LOW(r)==1 && I64HIGH(r)==0xfffffffe);
sl@0
  1140
sl@0
  1141
sl@0
  1142
	// /
sl@0
  1143
	test.Next(_L("Binary /"));
sl@0
  1144
	x=5;
sl@0
  1145
	y=5;
sl@0
  1146
	r=x/y;
sl@0
  1147
	test(I64INT(r)==1);
sl@0
  1148
sl@0
  1149
	y=1;
sl@0
  1150
	r=x/y;
sl@0
  1151
	test(I64INT(r)==5);
sl@0
  1152
sl@0
  1153
	x=-5;
sl@0
  1154
	r=x/y;
sl@0
  1155
	test(I64INT(r)==-5);
sl@0
  1156
sl@0
  1157
	y=-1;
sl@0
  1158
	r=x/y;
sl@0
  1159
	test(I64INT(r)==5);
sl@0
  1160
	
sl@0
  1161
	x=-1;
sl@0
  1162
	r=x/y;
sl@0
  1163
	test(I64INT(r)==1);
sl@0
  1164
sl@0
  1165
	x=0;
sl@0
  1166
	r=x/y;
sl@0
  1167
	test(I64INT(r)==0);
sl@0
  1168
sl@0
  1169
	x=KMinTInt32;
sl@0
  1170
	y=-1;
sl@0
  1171
	r=x/y;
sl@0
  1172
	test(I64INT(r)==KMinTInt32);
sl@0
  1173
sl@0
  1174
	x=KMinTInt32;
sl@0
  1175
	y=KMinTInt32;
sl@0
  1176
	r=x/y;
sl@0
  1177
	test(I64INT(r)==1);
sl@0
  1178
sl@0
  1179
	x=KMaxTUint32;
sl@0
  1180
	y=KMaxTUint32;
sl@0
  1181
	r=x/y;
sl@0
  1182
	test(I64INT(r)==1);
sl@0
  1183
sl@0
  1184
	x = MAKE_TINT64(KMaxTUint32,KMaxTUint32);
sl@0
  1185
	r=x/y;	   
sl@0
  1186
	test(I64INT(r)==0);
sl@0
  1187
sl@0
  1188
	y = MAKE_TINT64(KMaxTUint32,KMaxTUint32);
sl@0
  1189
	r=x/y;
sl@0
  1190
	test(I64INT(r)==1);
sl@0
  1191
sl@0
  1192
	y=KMinTInt32;
sl@0
  1193
	r=x/y;
sl@0
  1194
	test(I64INT(r)==0);
sl@0
  1195
  
sl@0
  1196
    x = MAKE_TINT64(4,257629747);
sl@0
  1197
    y=KMaxTInt;
sl@0
  1198
	r=x/y;
sl@0
  1199
	test(I64LOW(r)==8 && I64HIGH(r)==0);
sl@0
  1200
sl@0
  1201
	x = MAKE_TINT64(3452,533254);
sl@0
  1202
	x=-x;
sl@0
  1203
	x=x/x;
sl@0
  1204
	test(x==1);
sl@0
  1205
sl@0
  1206
  	// %
sl@0
  1207
	test.Next(_L("binary %%"));
sl@0
  1208
	x=2341;
sl@0
  1209
	y=2340;
sl@0
  1210
	test(x%y==1);
sl@0
  1211
	y=2;
sl@0
  1212
	test(x%y==1);
sl@0
  1213
	x = MAKE_TINT64(234893,23494);
sl@0
  1214
	test(x%x==0);
sl@0
  1215
	test(x%y==0);
sl@0
  1216
	x=-x;
sl@0
  1217
	y=10;
sl@0
  1218
	test(x%y==-2);
sl@0
  1219
	test(x%(-y)==-2);
sl@0
  1220
	
sl@0
  1221
					 
sl@0
  1222
	// Lsr
sl@0
  1223
	test.Next(_L("Lsr"));
sl@0
  1224
sl@0
  1225
	r = MAKE_TINT64(3,0);
sl@0
  1226
	I64LSR(r, 1);
sl@0
  1227
	test(I64HIGH(r)==1 && I64LOW(r)==0x80000000);
sl@0
  1228
	I64LSR(r, 1);
sl@0
  1229
	test(I64HIGH(r)==0 && I64LOW(r)==0xC0000000);
sl@0
  1230
sl@0
  1231
	r = MAKE_TINT64(0x80000000,0);  
sl@0
  1232
	I64LSR(r, 31);
sl@0
  1233
	test(I64HIGH(r)==1 && I64LOW(r)==0);
sl@0
  1234
	//test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==0);
sl@0
  1235
	I64LSR(r, 32);
sl@0
  1236
	//test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==KMaxTUint32);
sl@0
  1237
	test(I64HIGH(r)==0 && I64LOW(r)==1);
sl@0
  1238
sl@0
  1239
	r = MAKE_TINT64(0x80000000,0);
sl@0
  1240
	I64LSR(r, 32);
sl@0
  1241
	test(I64HIGH(r)==0 && I64LOW(r)==0x80000000);
sl@0
  1242
	//test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==0x80000000);
sl@0
  1243
sl@0
  1244
	r = MAKE_TINT64(0x80000000,0);
sl@0
  1245
	I64LSR(r, 63);
sl@0
  1246
	test(I64LOW(r)==1 && I64HIGH(r)==0);
sl@0
  1247
	//test(I64LOW(r)==KMaxTUint32 && I64HIGH(r)==KMaxTUint32);
sl@0
  1248
sl@0
  1249
	r = MAKE_TINT64(KMaxTUint32, 0);
sl@0
  1250
	I64LSR(r, 32);
sl@0
  1251
	test(I64HIGH(r)==0 && I64LOW(r)==KMaxTUint32);
sl@0
  1252
	//test(I64HIGH(r)==KMaxTUint32 && I64LOW(r)==KMaxTUint32);
sl@0
  1253
sl@0
  1254
sl@0
  1255
	// Mul10
sl@0
  1256
	test.Next(_L("Mul10"));
sl@0
  1257
	const TInt64 KMaxDiv10= KMaxTInt64 / 10;
sl@0
  1258
	const TInt64 KStep=MAKE_TINT64(0x003dfe03, 0xf7ea23cd);
sl@0
  1259
	for(TInt64 jj=-KMaxDiv10; jj<=KMaxDiv10; jj+=KStep)
sl@0
  1260
		{
sl@0
  1261
		r=jj;
sl@0
  1262
		r *= 10;
sl@0
  1263
		test(r==jj*10);
sl@0
  1264
		r/=10;
sl@0
  1265
		test(r==jj);
sl@0
  1266
		}
sl@0
  1267
sl@0
  1268
	r=KMinTInt32/10;
sl@0
  1269
	r *= 10;
sl@0
  1270
	test(I64INT(r)==(KMinTInt/10)*10);
sl@0
  1271
sl@0
  1272
	r=KMaxTUint32;
sl@0
  1273
	r *= 10;
sl@0
  1274
	test(I64HIGH(r)==9 && I64LOW(r)==0xFFFFFFF6);
sl@0
  1275
sl@0
  1276
	r/=10;
sl@0
  1277
	test(r==MAKE_TINT64(0,KMaxTUint32));
sl@0
  1278
sl@0
  1279
sl@0
  1280
	// DivMod
sl@0
  1281
	test.Next(_L("DivMod"));
sl@0
  1282
	TInt64 seed = MAKE_TINT64(0x0000336a,0xb2001a78);
sl@0
  1283
	for (TInt i=0; i<200; i++)
sl@0
  1284
		{
sl@0
  1285
		TInt o=Math::Rand(seed);
sl@0
  1286
		TInt p=Math::Rand(seed);
sl@0
  1287
		TInt r=Math::Rand(seed);
sl@0
  1288
		TInt q=Math::Rand(seed);
sl@0
  1289
sl@0
  1290
		DivModTest(MAKE_TINT64(0,q), MAKE_TINT64(0,r));
sl@0
  1291
		DivModTest(MAKE_TINT64(r,q), MAKE_TINT64(o,p));
sl@0
  1292
		DivModTest(MAKE_TINT64(p,q), MAKE_TINT64(0,o));
sl@0
  1293
		DivModTest(MAKE_TINT64(0,p), MAKE_TINT64(r,o));
sl@0
  1294
		
sl@0
  1295
		DivModTest(-MAKE_TINT64(0,q), -MAKE_TINT64(0,r));
sl@0
  1296
		DivModTest( MAKE_TINT64(0,q), -MAKE_TINT64(0,r));
sl@0
  1297
		DivModTest(-MAKE_TINT64(0,q),  MAKE_TINT64(0,r));
sl@0
  1298
sl@0
  1299
		DivModTest(-MAKE_TINT64(r,q), -MAKE_TINT64(o,p));
sl@0
  1300
		DivModTest( MAKE_TINT64(r,q), -MAKE_TINT64(o,p));
sl@0
  1301
		DivModTest(-MAKE_TINT64(r,q),  MAKE_TINT64(o,p));
sl@0
  1302
sl@0
  1303
		DivModTest(-MAKE_TINT64(0,p), -MAKE_TINT64(r,o));
sl@0
  1304
 		DivModTest( MAKE_TINT64(0,p), -MAKE_TINT64(r,o));
sl@0
  1305
		DivModTest(-MAKE_TINT64(0,p),  MAKE_TINT64(r,o));
sl@0
  1306
		}
sl@0
  1307
sl@0
  1308
	test.End();
sl@0
  1309
	}
sl@0
  1310
sl@0
  1311
LOCAL_C void Test5()
sl@0
  1312
// still more operators
sl@0
  1313
	{
sl@0
  1314
sl@0
  1315
	// fast multiply by 10
sl@0
  1316
	test.Start(_L("Mul10"));
sl@0
  1317
   	TInt64 r(0);
sl@0
  1318
	r *= 10;
sl@0
  1319
	test(I64INT(r)==0);
sl@0
  1320
sl@0
  1321
	r=-1;
sl@0
  1322
	r *= 10;
sl@0
  1323
	test(I64INT(r)==-10);
sl@0
  1324
sl@0
  1325
	r=KMinTInt32/10;
sl@0
  1326
	r *= 10;
sl@0
  1327
	test(I64INT(r)==KMinTInt32-(KMinTInt32%10));
sl@0
  1328
sl@0
  1329
	r=1;
sl@0
  1330
	r *= 10;
sl@0
  1331
	test(I64INT(r)==10);
sl@0
  1332
sl@0
  1333
	r=KMaxTUint32/10;
sl@0
  1334
	r *= 10;
sl@0
  1335
	test(I64LOW(r)==(KMaxTUint32-(KMaxTUint%10)) && I64HIGH(r)==0);
sl@0
  1336
sl@0
  1337
	r *= 10;
sl@0
  1338
	test(r==TInt64(KMaxTUint32-(KMaxTUint%10))*10);
sl@0
  1339
sl@0
  1340
	r *= 10;
sl@0
  1341
	test(r==TInt64(KMaxTUint32-(KMaxTUint%10))*100);
sl@0
  1342
sl@0
  1343
 	// Comparisons
sl@0
  1344
	test.Next(_L("Comparison operators"));
sl@0
  1345
sl@0
  1346
	// == , !=, <= and >=
sl@0
  1347
	test.Next(_L("==, !=, <= and >="));
sl@0
  1348
	r=KMinTInt32;
sl@0
  1349
	TInt64 x(KMinTInt32);
sl@0
  1350
	TInt64 y(100);
sl@0
  1351
	test(r==x && r!=y && r>=x && r<=x);
sl@0
  1352
sl@0
  1353
	r=-1;
sl@0
  1354
	x=-1;
sl@0
  1355
	test(r==x && r!=y && r>=x && r<=x);
sl@0
  1356
sl@0
  1357
	r=0;
sl@0
  1358
	x=0;
sl@0
  1359
	test(r==x && r!=y && r>=x && r<=x);
sl@0
  1360
sl@0
  1361
	r=1;
sl@0
  1362
	x=1;
sl@0
  1363
	test(r==x && r!=y && r>=x && r<=x);
sl@0
  1364
sl@0
  1365
	r=KMaxTUint32;
sl@0
  1366
	x=KMaxTUint32;
sl@0
  1367
	test(r==x && r!=y && r>=x && r<=x);
sl@0
  1368
sl@0
  1369
	r = MAKE_TINT64(KMaxTUint32,KMaxTUint32);
sl@0
  1370
	x = MAKE_TINT64(KMaxTUint32,KMaxTUint32);
sl@0
  1371
	test(x==r && x!=y && x>=r && x<=r);
sl@0
  1372
sl@0
  1373
	//>=, <=, > and <
sl@0
  1374
	test.Next(_L(">=, <=, > and <"));
sl@0
  1375
	r=KMinTInt32;
sl@0
  1376
	x=KMinTInt32+1;
sl@0
  1377
	test(x>r && x>=r && r<x && r<=x);
sl@0
  1378
sl@0
  1379
	r=1;
sl@0
  1380
	x=-1;
sl@0
  1381
	test(r>x && x<r && r>=x && x<=r);
sl@0
  1382
sl@0
  1383
	r=KMaxTUint32;
sl@0
  1384
	x=KMaxTUint32-1;
sl@0
  1385
	test(r>x && x<r && r>=x && x<=r);
sl@0
  1386
sl@0
  1387
	r+=1;
sl@0
  1388
	x+=1;
sl@0
  1389
	test(r>x && x<r && r>=x && x<=r);
sl@0
  1390
sl@0
  1391
	r = MAKE_TINT64(KMaxTUint32,KMaxTUint32);
sl@0
  1392
	x = MAKE_TINT64(KMaxTUint32,KMaxTUint32-1);
sl@0
  1393
	test(r>x && x<r && r>=x && x<=r);
sl@0
  1394
sl@0
  1395
	r = MAKE_TINT64(0x80000000,0);
sl@0
  1396
	x = MAKE_TINT64(KMaxTInt32,KMaxTUint32);
sl@0
  1397
	test(r<x);
sl@0
  1398
	test(x>r);
sl@0
  1399
	test(x!=r);
sl@0
  1400
	test(r<=x);
sl@0
  1401
	test(x>=r);
sl@0
  1402
	test(r<0 && x>0);
sl@0
  1403
sl@0
  1404
	x = MAKE_TINT64(0x80000000,1);
sl@0
  1405
	test(r<x && x>r && x!=r && r<=x && x>=r);
sl@0
  1406
sl@0
  1407
	r = MAKE_TINT64(KMaxTInt32,KMaxTUint32);
sl@0
  1408
	--r;
sl@0
  1409
	test(r>x && x<r && x!=r && r>=x && x<=r);
sl@0
  1410
sl@0
  1411
	// multiply top bits
sl@0
  1412
	test.Next(_L("MulTop"));
sl@0
  1413
   	r=0;
sl@0
  1414
    x=0;
sl@0
  1415
	I64MULTOP(r, x);
sl@0
  1416
	test(I64INT(r)==0);
sl@0
  1417
sl@0
  1418
	r=1;
sl@0
  1419
    x=1;
sl@0
  1420
	I64MULTOP(r, x);
sl@0
  1421
	test(I64INT(r)==0);
sl@0
  1422
sl@0
  1423
	r = MAKE_TINT64(KMaxTInt,KMaxTUint);
sl@0
  1424
    x=2;
sl@0
  1425
	I64MULTOP(r, x);
sl@0
  1426
	test(I64INT(r)==0);
sl@0
  1427
sl@0
  1428
	r = MAKE_TINT64(KMaxTInt,KMaxTUint);
sl@0
  1429
    x=4;
sl@0
  1430
	I64MULTOP(r, x);
sl@0
  1431
	test(I64INT(r)==1);
sl@0
  1432
sl@0
  1433
    r = MAKE_TINT64(0x80000000,0);
sl@0
  1434
    x = MAKE_TINT64(0x80000000,0);
sl@0
  1435
	I64MULTOP(r, x);
sl@0
  1436
    r>>=32;
sl@0
  1437
	test(I64INT(r)==0x40000000);
sl@0
  1438
sl@0
  1439
    r = MAKE_TINT64(0x18763529,0x93263921);
sl@0
  1440
    x = MAKE_TINT64(0x0abcdef0,0x647239ea);
sl@0
  1441
    TInt64 r2=r;
sl@0
  1442
    TInt64 x2=x;
sl@0
  1443
    I64MULTOP(r, x2);
sl@0
  1444
    I64MULTOP(x, r2);
sl@0
  1445
    test(r==x);
sl@0
  1446
sl@0
  1447
//	TInt64(0xac11b680,0x1e603000) * TInt64(0x014a5c20,0xc9d58740)
sl@0
  1448
sl@0
  1449
	TPtrC8 a4=_L8("ac11b6801e603000");
sl@0
  1450
	TPtrC8 a5=_L8("014a5c20c9d58740");
sl@0
  1451
	TBuf8<64> a6;
sl@0
  1452
	HexMul(a4,a5,a6);
sl@0
  1453
sl@0
  1454
	x = MAKE_TINT64(0x014a5c20,0xc9d58740); 
sl@0
  1455
sl@0
  1456
	r = MAKE_TINT64(0xac11b680,0x1e603000);
sl@0
  1457
	y = MAKE_TINT64(0x0963fbc4,0x415c0000); // Expected result (bottom 64 bits)
sl@0
  1458
sl@0
  1459
	r *= x;
sl@0
  1460
sl@0
  1461
	test(r==y);
sl@0
  1462
sl@0
  1463
	r = MAKE_TINT64(0xac11b680,0x1e603000);
sl@0
  1464
	y = MAKE_TINT64(0x00de0cc1,0xa89d70dc); // Expected result (top 64 bits)
sl@0
  1465
	I64MULTOP(r, x);
sl@0
  1466
	test(r==y);
sl@0
  1467
sl@0
  1468
	test.End();
sl@0
  1469
	}
sl@0
  1470
sl@0
  1471
sl@0
  1472
GLDEF_C TInt E32Main()
sl@0
  1473
    {
sl@0
  1474
	test.Title();
sl@0
  1475
	test.Start(_L("Constructors"));
sl@0
  1476
	Test1();
sl@0
  1477
	test.Next(_L("Unary operators"));
sl@0
  1478
	Test1_2();
sl@0
  1479
	test.Next(_L("Operators 1"));
sl@0
  1480
	Test2();
sl@0
  1481
	test.Next(_L("Operators 2"));
sl@0
  1482
	Test3();
sl@0
  1483
	test.Next(_L("Operators 3"));
sl@0
  1484
	Test4();
sl@0
  1485
	test.Next(_L("Operators 4"));
sl@0
  1486
	Test5();
sl@0
  1487
	test.End();
sl@0
  1488
	return(KErrNone);
sl@0
  1489
    }