thats how floating points works..

On Wed, Sep 17, 2008 at 12:57 PM, <[EMAIL PROTECTED]> wrote:

> I have a a Java Object that implements the Scriptable interface and
> returns the value -0.58*100 from the get method. The result I expect
> is -58 of course but actually the result I get is -57.99999999999999.
> Here is the code of the Java object that implements Scriptable
> interface:
>
>   class DummyScript extends BaseScriptable {
>         public Object get(String s, Scriptable scriptable) {
>             Double result;
>             double src = -0.58;
>             result = new Double(src*100);
>             return result;
>         }
>    }
>
> Does anyone know why this happens? I know rounding problems are to be
> expected with large numbers of digits in any computer program but in
> this very simple case its unacceptable. I can provide the full Test
> Source which is very small as I have created a cut down test case for
> this.
> _______________________________________________
> dev-tech-js-engine-rhino mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
>
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to