jdk/test/java/lang/StrictMath/Tests.java
changeset 32928 a3f03999ed62
parent 5506 202f599c92aa
equal deleted inserted replaced
32917:8392405ab038 32928:a3f03999ed62
     1 /*
     1 /*
     2  * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    58         }
    58         }
    59         else
    59         else
    60             return 0;
    60             return 0;
    61     }
    61     }
    62 
    62 
       
    63     /**
       
    64      * Returns a double over the normalized range of floating-point values.
       
    65      * @return a double over the normalized range of floating-point values
       
    66      */
       
    67     static double createRandomDouble(java.util.Random random) {
       
    68         final int EXPONENT_RANGE = Double.MAX_EXPONENT - Double.MIN_EXPONENT + 1;
    63 
    69 
    64 
    70         int targetExponent = Double.MIN_EXPONENT + random.nextInt(EXPONENT_RANGE + 1);
       
    71         double tmp = random.nextDouble(); // Double in the range of [0.0, 1.0)
       
    72         int tmpExponent = Math.getExponent(tmp);
       
    73         return Math.scalb(tmp, targetExponent - tmpExponent);
       
    74     }
    65 }
    75 }