Another odd thing is that if you move the * 10000 inside of convert
(actually, adding a convert2 instead of replacing the current code), it
returns the correct number but things like changing the order of the
calculation inside of the method do not correct the error. Also,
compiling the same code under jdk1.4 works fine. This sounds like a
stupid question to me but is there a disassembler for byte code (not
refactoring) that produces symbolic byte code?
wjr
James Park wrote:
It's strange though. For every other number I've tried besides 10.25,
the results match.
------------------------------------------------------------------------
> Date: Thu, 13 Apr 2006 09:15:08 +0200
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> CC: [email protected]
> Subject: Re: [Lejos-discussion] Arithmetic Problem
>
> Hi James,
>
> James Park <[EMAIL PROTECTED]> wrote:
> >
> > In the following program, the LCD will print 4999 first
> > (incorrect), and then 5031 second (correct). I'm not
> > missing something obvious am I?
>
> note that double arithmetic is not implemented,
> I think float arithmetic is done instead.
> So the conversion to double and back could be the culprit,
> but that needs to be verified.
>
> > import josx.platform.rcx.*;
> >
> > public class Program {
> > public static void main(String[] args) {
> > present((int)(convert(10.25) * 10000));
> > present((int)((10.25 * 2 * Math.PI / 128) * 10000));
> ^^^^^
> This is float.
>
> > }
> >
> > private static double convert(double ticks) {
> > return ticks * 2 * Math.PI / 128;
> ^^^^^
> This is double.
>
> > }
> >
> > private static void present(int number) {
> > LCD.showNumber(number);
> > try {
> > Button.PRGM.waitForPressAndRelease();
> > } catch (InterruptedException e) {
> > }
> > }
> > }
>
>
> Greetings
>
> Jürgen
>
> --
> Jürgen Stuber <[EMAIL PROTECTED]>
> http://www.jstuber.net/
>
gnupg key fingerprint = 2767 CA3C 5680 58BA 9A91 23D9 BED6 9A7A AF9E 68B4
------------------------------------------------------------------------
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Lejos-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lejos-discussion