From f05318b78785fa7dbd5718caee08b7b5da0bc19f Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 22 May 2008 18:08:41 -0600 Subject: [PATCH] fix thinkos in d2i and friends --- src/compile.cpp | 15 ++++++++++----- test/Floats.java | 13 +++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/compile.cpp b/src/compile.cpp index 4fee8788b7..f11b69d367 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -2094,21 +2094,24 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, frame->pushInt (c->call (c->constant(reinterpret_cast(doubleToFloat)), - Compiler::Indirect, 0, 4, 1, frame->popLong())); + Compiler::Indirect, 0, 4, 2, + static_cast(0), frame->popLong())); } break; case d2i: { frame->pushInt (c->call (c->constant(reinterpret_cast(doubleToInt)), - Compiler::Indirect, 0, 4, 1, frame->popLong())); + Compiler::Indirect, 0, 4, 2, + static_cast(0), frame->popLong())); } break; case d2l: { frame->pushLong (c->call (c->constant(reinterpret_cast(doubleToLong)), - Compiler::Indirect, 0, 8, 1, frame->popLong())); + Compiler::Indirect, 0, 8, 2, + static_cast(0), frame->popLong())); } break; case dadd: { @@ -2866,14 +2869,16 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, frame->pushLong (c->call (c->constant(reinterpret_cast(longToDouble)), - Compiler::Indirect, 0, 8, 1, frame->popLong())); + Compiler::Indirect, 0, 8, 2, + static_cast(0), frame->popLong())); } break; case l2f: { frame->pushInt (c->call (c->constant(reinterpret_cast(longToFloat)), - Compiler::Indirect, 0, 4, 1, frame->popLong())); + Compiler::Indirect, 0, 4, 2, + static_cast(0), frame->popLong())); } break; case l2i: diff --git a/test/Floats.java b/test/Floats.java index 4db89a233c..655935d03f 100644 --- a/test/Floats.java +++ b/test/Floats.java @@ -32,5 +32,18 @@ public class Floats { expect(divide(0.5d, 0.5d) == 1.0d); expect(subtract(0.5d, 0.5d) == 0.0d); + + double d = 1d; + expect(((int) d) == 1); + + expect(Math.round(0.4f) == 0); + expect(Math.round(0.5f) == 1); + expect(Math.round(1.0f) == 1); + expect(Math.round(1.9f) == 2); + + expect(Math.round(0.4d) == 0); + expect(Math.round(0.5d) == 1); + expect(Math.round(1.0d) == 1); + expect(Math.round(1.9d) == 2); } }