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
- [Lejos-discussion] Arithmetic Problem James Park
- Re: [Lejos-discussion] Arithmetic Problem Juergen Stuber
- RE: Re: [Lejos-discussion] Arithmetic Problem James Park
- Re: [Lejos-discussion] Arithmetic Problem William J Rust
- Re: [Lejos-discussion] Arithmetic Problem Juergen Stuber
