fix thinkos in d2i and friends

This commit is contained in:
Joel Dice 2008-05-22 18:08:41 -06:00
parent 3326aafdac
commit f05318b787
2 changed files with 23 additions and 5 deletions

View File

@ -2094,21 +2094,24 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
frame->pushInt
(c->call
(c->constant(reinterpret_cast<intptr_t>(doubleToFloat)),
Compiler::Indirect, 0, 4, 1, frame->popLong()));
Compiler::Indirect, 0, 4, 2,
static_cast<Compiler::Operand*>(0), frame->popLong()));
} break;
case d2i: {
frame->pushInt
(c->call
(c->constant(reinterpret_cast<intptr_t>(doubleToInt)),
Compiler::Indirect, 0, 4, 1, frame->popLong()));
Compiler::Indirect, 0, 4, 2,
static_cast<Compiler::Operand*>(0), frame->popLong()));
} break;
case d2l: {
frame->pushLong
(c->call
(c->constant(reinterpret_cast<intptr_t>(doubleToLong)),
Compiler::Indirect, 0, 8, 1, frame->popLong()));
Compiler::Indirect, 0, 8, 2,
static_cast<Compiler::Operand*>(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<intptr_t>(longToDouble)),
Compiler::Indirect, 0, 8, 1, frame->popLong()));
Compiler::Indirect, 0, 8, 2,
static_cast<Compiler::Operand*>(0), frame->popLong()));
} break;
case l2f: {
frame->pushInt
(c->call
(c->constant(reinterpret_cast<intptr_t>(longToFloat)),
Compiler::Indirect, 0, 4, 1, frame->popLong()));
Compiler::Indirect, 0, 4, 2,
static_cast<Compiler::Operand*>(0), frame->popLong()));
} break;
case l2i:

View File

@ -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);
}
}