|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 4 of 5
| Opcode | Operand(s) | Description |
|---|---|---|
| fsub | (none) | pops two floats, subtracts them, and pushes the float result |
| dsub | (none) | pops two doubles, subtracts them, and pushes the double result |
Multiplication of floats and doubles is accomplished via the following opcodes. Each opcode causes two values of the same type to be popped off the stack and multiplied. The result, of the same type as the numbers being multiplied, is pushed back onto the stack. No exceptions are thrown.
| Opcode | Operand(s) | Description |
|---|---|---|
| fmul | (none) | pops two floats, multiplies them, and pushes the float result |
| dmul | (none) | pops two doubles, multiplies them, and pushes the double result |
The division experience is made available for floats and doubles by the following opcodes. The division opcodes cause the top two values of the appropriate type to be popped off the stack. The topmost value is divided by the value immediately beneath the topmost value. The result is pushed onto the stack. Floating-point division of a finite value by zero yields a positive or negative infinity. Floating-point division of zero by zero yields NaN. No exception is thrown as a result of any floating-point division.
| Opcode | Operand(s) | Description |
|---|---|---|
| fdiv | (none) | pops two floats, divides them, and pushes the float result |
| ddiv | (none) | pops two doubles, divides them, and pushes the double result |
The remainder operation is accomplished via the following opcodes on floats and doubles. The following opcodes cause the top two values to be popped from the stack. The topmost value is divided by the value just beneath it, and the remainder of that division is pushed back onto the stack. Floating-point remainder of any value divided by zero yields a NaN result. No exception is thrown as a result of any floating-point division.
| Opcode | Operand(s) | Description |
|---|---|---|
| frem | (none) | pops two floats, divides them, and pushes the float remainder |
| drem | (none) | pops two doubles, divides them, and pushes the double remainder |
The following opcodes perform arithmetic negation on floats and doubles. Negation opcodes pop the top value from the stack, negates it, and pushes the result.
| Opcode | Operand(s) | Description |
|---|---|---|
| fneg | (none) | pops a float, negates it, and pushes the result |
| dneg | (none) | pops a double, negates it, and pushes the result |
class Struggle {
static void squareItForever() {
float f = 2;
while (true) {
f = f * f;
f = 0 - f;
}
}
}
The actual bytecodes generated by javac for squareItForever() are shown below:
fconst_2 // Push float constant 2.
fstore_0 // Pop to local variable 0 (float f): float f = 2;
fload_0 // Push local variable 0 (float f).
fload_0 // Push local variable 0 (float f).
fmul // Pop top two floats, multiply, push float result.
fstore_0 // Pop to local variable 0 (float f): f = f * f;
fconst_0 // Push float constant 0.
fload_0 // Push local variable 0 (float f).
fsub // Subtract top float from next to top float: imByte = (byte) imInt;
fstore_0 // Pop result to local variable 0 (float f): f = 0 - f;
goto 2 // Jump back to the first fload_0 instruction: while (true) {}
The squareItForever() method repeatedly squares a float value until it hits infinity. Each time the float is squared it is also negated. The float starts out as 2. It only takes seven iterations before infinity is reached, which isn't nearly as long as it takes in real life. The hex representation of the bits that make up the float are shown in the "hex value" column in the applet. The "value" column shows the number as humans are used to seeing it. This human-friendly value is generated by the Float.toString() method.