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&kid0944&bid$1720&dat1642
_______________________________________________
Lejos-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lejos-discussion

Reply via email to