class Main { publicstaticvoid main(String[] args) {
testIntShiftRight();
testIntShiftLeft();
testIntUnsignedShiftRight();
testLongShiftRight();
testLongShiftLeft();
testLongUnsignedShiftRight();
}
publicstaticvoid testIntShiftLeft() { int a = myField; int b = myOtherField << a; if (b != -2147483648) { thrownew Error("Expected -2147483648, got " + b);
} if (a != 0xFFF) { thrownew Error("Expected 0xFFF, got " + a);
}
}
publicstaticvoid testIntShiftRight() { int a = myField; int b = myOtherField >> a; if (b != 0) { thrownew Error("Expected 0, got " + b);
} if (a != 0xFFF) { thrownew Error("Expected 0xFFF, got " + a);
}
}
publicstaticvoid testIntUnsignedShiftRight() { int a = myField; int b = myOtherField >>> a; if (b != 0) { thrownew Error("Expected 0, got " + b);
} if (a != 0xFFF) { thrownew Error("Expected 0xFFF, got " + a);
}
}
publicstaticvoid testLongShiftLeft() { long a = myLongField; long b = myOtherLongField << a; if (b != 0x2468ACF13579BDEL) { thrownew Error("Expected 0x2468ACF13579BDEL, got " + b);
} // The int conversion will be GVN'ed with the one required // by Java specification of long shift left. if ((int)a != 0x41) { thrownew Error("Expected 0x41, got " + a);
}
}
publicstaticvoid testLongShiftRight() { long a = myLongField; long b = myOtherLongField >> a; if (b != 0x91A2B3C4D5E6F7L) { thrownew Error("Expected 0x91A2B3C4D5E6F7L, got " + b);
} // The int conversion will be GVN'ed with the one required // by Java specification of long shift right. if ((int)a != 0x41) { thrownew Error("Expected 0x41, got " + a);
}
}
publicstaticvoid testLongUnsignedShiftRight() { long a = myLongField; long b = myOtherLongField >>> a; if (b != 0x91A2B3C4D5E6F7L) { thrownew Error("Expected 0x91A2B3C4D5E6F7L, got " + b);
} // The int conversion will be GVN'ed with the one required // by Java specification of long shift right. if ((int)a != 0x41) { thrownew Error("Expected 0x41, got " + a);
}
}
// Use a value that will need to be masked before doing the shift. // The maximum shift is 0x3F. staticlong myLongField = 0x41; staticlong myOtherLongField = 0x123456789abcdefL;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.