Subject: [NEXTEL-1] J2ME tools - Float point MIDP calculations

From: [email-masked]
Date: Thu, 15 Jul 2004 02:08:09 -0400

http://henson.newmail.ru/j2me/Float.htm

------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/61FxlB/TM
--------------------------------------------------------------------~-> 

-- 
    "NEXTEL-1 IT'S NOT JUST NEXTEL"
  Note The New address 
Subscribe to Nextel-1: http://www.groups.yahoo.com/subscribe/NEXTEL-1

  "NEXTEL2 FOR iDEN SOFTWARE DEVELOPERS"
Subscribe to Nextel2: http://www.groups.yahoo.com/subscribe/NEXTEL2

  "WIRELESS FORUM HOMELAND SECURITY GROUP"
     The Complete Resource for Wireless Homeland Security.
Subscribe to WFHSG:  http://www.groups.yahoo.com/subscribe/WFHSG

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/NEXTEL-1/

<*> To unsubscribe from this group, send an email to:
    [email-masked]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 
_Nikolay Klimchuk_

Personal
office in

the digital world

henson.midp.Float (ver 0.98)

Fill the power => 64bit for mantissa, 64bit for exponent

Check also: henson.midp.Float11
and FloatConv

Methods and properties
▼

Non-static members

Static members

Constants

Float()

Float(long value)

Float(long value, long e)

Float(Float value)

String toString()

Float Add(Float value)

Float Sub(Float value)

Float Mul(long value)

Float Mul(Float value)

Float Div(long value)

Float Div(Float value)

boolean Great(Float x)

boolean Less(Float x)

boolean Equal(Float x)

Float Neg()

long toLong()

boolean isError()

Float sin(Float x)

Float cos(Float x)

Float sqrt(Float x)

Float tan(Float x)

Float asin(Float x)

Float acos(Float x)

Float atan(Float x)

Float atan2(Float x, Float y)

Float parse(String str, int radix)

Float exp(Float x)

Float log(Float x)

Float log10(Float x)

Float pow(Float x, Float y)

Float ceil(Float x)

Float floor(Float x)

Float abs(Float x)

Float Int(Float x)

Float Frac(Float x)

Float toRadians(Float x)

Float toDegrees(Float x)

Float ERROR

Float ZERO

Float ONE

Float PI - pi

Float E - Euler's constant

Float LOG10 - Natural logarithm of 10

Float PIdiv2 - pi/2

Float PIdiv4 - pi/4

Float PIdiv6 - pi/6

Float PIdiv12 - pi/12

Float PImul2 - pi*2

Float PImul4 - pi*4

Most of these members is absent in java.util.Math class of the CLDC 1.0. Syntax
of methods is similar
used in full J2SE/EE implementation of java.util.Math. Algorithms was tested to
make calculations fast and precisely. In new specification CLDC 1.1 were appended
double and float types, but anyway some methods for example acos/asin/atan is
absent.

Comparing results in J2SE test application
▼

//
Source code to compare nature java.util.Math and henson.midp.Float classes
in J2SE/EE test application

for(int i=0; i<540; i++)

{

//
degrees to radians conversion

double arg=(double)i*3.14159265359/180.0;

henson.midp.Float arg2=new henson.midp.Float((long)(arg*1000000), -6);

henson.midp.Float r2sin=henson.midp.Float.sin(arg2);

double r1sin=Math.sin(arg);

henson.midp.Float r2cos=henson.midp.Float.cos(arg2);

double r1cos=Math.cos(arg);

henson.midp.Float r2tan=henson.midp.Float.tan(arg2);

double r1tan=Math.tan(arg);

henson.midp.Float r2atan=henson.midp.Float.atan(arg2);

double r1atan=Math.atan(arg);

henson.midp.Float r2asin=henson.midp.Float.asin(arg2);

double r1asin=Math.asin(arg);

//

list1.add("SIN Angle:"+i+" JAVA.LANG.MATH:"+r1sin+"
HENSON.MIDP.FLOAT:"+r2sin.toString());

list1.add("TAN Angle:"+i+" JAVA.LANG.MATH:"+r1tan+"
HENSON.MIDP.FLOAT:"+r2tan.toString());

list1.add("COS Angle:"+i+" JAVA.LANG.MATH:"+r1cos+"
HENSON.MIDP.FLOAT:"+r2cos.toString());

list1.add("ATAN Angle:"+i+" JAVA.LANG.MATH:"+r1atan+"
HENSON.MIDP.FLOAT:"+r2atan.toString());

list1.add("ASIN Angle:"+i+" JAVA.LANG.MATH:"+r1asin+"
HENSON.MIDP.FLOAT:"+r2asin.toString());

}

FloatTest

FloatTest will test
performance of float point calculations with henson.midp.Float class direct on
J2ME devices. It's may be as long as 60 seconds or even more.

Model

sin,
ms

100 times

cos,
ms

100 times

tan,
ms

100 times

add,
ms

10000 times

mul,
ms

10000 times

div,
ms

10000 times

sqrt,
ms

1000 times

MOBILE PHONES

/-\ Nokia

N-Gage

1016

594

1641

1297

3438

6328

4219

6310i

4370

2461

7089

5363

14673

24131

20402

3510i

4202

2435

6837

5324

14550

22370

16678

6100

4407

2534

7065

5410

14905

23794

16069

6610

4381

2511

7158

5492

15056

23874

17318

3650

1094

609

1766

1297

3484

7031

4641

7650

765

453

1265

1031

2515

5328

???

6600

328

157

500

188

547

3235

1328

6220

6086

3623

10149

8325

22395

32238

23670

7600

494

290

795

614

1578

2482

1622

3100

6727

3967

10949

9054

24905

36291

26268

6230

965

538

1654

1088

3212

5165

*

7250

4254

2431

7052

5466

14943

22483

14524

7610

281

141

438

187

453

2719

1109

/-\ Siemens

S55

28899

16559

50899

36306

101370

200670

169181

M55

30441

17025

53584

38420

105500

207800

???

SX1

1110

672

1875

1563

3985

7141

4203

/-\ SonyEricsson

K700i
(new)

712

370

1085

639

1687

3049

1864

T610

20580

11575

33585

28100

71365

87740

76280

T610
(R3C)

8780

5055

14515

11385

30440

42120

34595

T610
(R6C)

9875

5575

16210

12235

33295

49410

37920

P900

250

109

344

156

406

2203

1062

P800

500

282

813

625

1563

3250

1750

Thank you
to Dmitry Gorilowsky for measurements

PDA

/-\ Sony

Clie
N610

48830

24960

84770

35810

102100

445530

206440

Download
FloatTest midlet (11kB)

http://henson.newmail.ru/j2me/FloatTest.jad

http://henson.newmail.ru/j2me/FloatTest.jar

Via WAP

http://henson.newmail.ru/j2me/FloatTest.wml

At
last

As an example of using float point calculations with henson.midp.Float class I make simple space simulator for Nokia mobile phones
which called MoonLight. Your mission is to make success
flight from one point on the surface of the Moon to the second.

If you have some bugs (why not?) with that class please send
me message at [email-masked] or
[email-masked]. Thank you!

Design by Nick Henson ©, 2002-2003