/*
* Copyright ( C ) 2014 The Android Open Source Project
*
* Licensed under the Apache License , Version 2 . 0 ( the " License " ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an " AS IS " BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
*/
public class Main {
static double dPi = Math.PI;
static float fPi = (float )Math.PI;
public static void expectEquals(long expected, long result) {
if (expected != result) {
throw new Error("Expected: " + expected + ", found: " + result);
}
}
public static void expectEquals(int expected, int result) {
if (expected != result) {
throw new Error("Expected: " + expected + ", found: " + result);
}
}
public static void divDoubleTest() {
double d1 = 0 x1.0 p1023;
double d2 = -2 .0 ;
double d3 = 0 .0 ;
double d4 = Double .MIN_NORMAL;
double d5 = Double .POSITIVE_INFINITY;
double d6 = Double .NEGATIVE_INFINITY;
double d7 = -0 .0 ;
double d8 = Double .MAX_VALUE;
double d9 = Double .MIN_VALUE;
double dNaN = Double .NaN;
expectEquals(Double .doubleToRawLongBits(dPi/d1), 0 x1921fb54442d18L);
expectEquals(Double .doubleToRawLongBits(dPi/d2), 0 xbff921fb54442d18L);
expectEquals(Double .doubleToRawLongBits(dPi/d3), 0 x7ff0000000000000L);
expectEquals(Double .doubleToRawLongBits(dPi/d4), 0 x7fe921fb54442d18L);
expectEquals(Double .doubleToRawLongBits(dPi/d5), 0 x0L);
expectEquals(Double .doubleToRawLongBits(dPi/d6), 0 x8000000000000000L);
expectEquals(Double .doubleToRawLongBits(dPi/d7), 0 xfff0000000000000L);
expectEquals(Double .doubleToRawLongBits(dPi/d8), 0 xc90fdaa22168cL);
expectEquals(Double .doubleToRawLongBits(dPi/d9), 0 x7ff0000000000000L);
// Not-a-number computation. Use doubleToLongBits to get canonical NaN. The literal value
// is the canonical NaN (see Double.doubleToLongBits).
expectEquals(Double .doubleToLongBits(dPi/dNaN), 0 x7ff8000000000000L);
}
public static void divFloatTest() {
float f1 = 0 x1.0 p127f;
float f2 = -2 .0 f;
float f3 = 0 .0 f;
float f4 = Float .MIN_NORMAL;
float f5 = Float .POSITIVE_INFINITY;
float f6 = Float .NEGATIVE_INFINITY;
float f7 = -0 .0 f;
float f8 = Float .MAX_VALUE;
float f9 = Float .MIN_VALUE;
float fNaN = Float .NaN;
expectEquals(Float .floatToRawIntBits(fPi/f1), 0 xc90fdb);
expectEquals(Float .floatToRawIntBits(fPi/f2), 0 xbfc90fdb);
expectEquals(Float .floatToRawIntBits(fPi/f3), 0 x7f800000);
expectEquals(Float .floatToRawIntBits(fPi/f4), 0 x7f490fdb);
expectEquals(Float .floatToRawIntBits(fPi/f5), 0 x0);
expectEquals(Float .floatToRawIntBits(fPi/f6), 0 x80000000);
expectEquals(Float .floatToRawIntBits(fPi/f7), 0 xff800000);
expectEquals(Float .floatToRawIntBits(fPi/f8), 0 x6487ee);
expectEquals(Float .floatToRawIntBits(fPi/f9), 0 x7f800000);
// Not-a-number computation. Use floatToIntBits to get canonical NaN. The literal value
// is the canonical NaN (see Float.floatToIntBits).
expectEquals(Float .floatToIntBits(fPi/fNaN), 0 x7fc00000);
}
public static void main(String[] args) {
divDoubleTest();
divFloatTest();
System.out.println("Done!" );
}
}
Messung V0.5 in Prozent C=81 H=89 G=84
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet am 2026-06-29)
¤
*© Formatika GbR, Deutschland