Here you can find the source of getDoubleSpecial()
static double getDoubleSpecial()
//package com.java2s; /*/* w w w .j a v a2s . c om*/ * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ import java.util.Random; public class Main { static Random rng; static double[] dspecial = { 0, 1, 2, 4, 8, 256, 16384, 32768, 65536, .1, .25, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, Float.MIN_VALUE, Float.MAX_VALUE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.MIN_VALUE, Double.MAX_VALUE }; static double getDoubleSpecial() { int i = rng.nextInt(); long j = rng.nextLong(); double f = Double.longBitsToDouble(j); if (f != f) f = 0; // get rid of NaN for comparison purposes if ((i & 0x10) != 0) return f; return dspecial[((int) j & 0x7fffffff) % dspecial.length] * ((i & 0x20) == 0 ? 1 : -1) + ((i & 0x03) - 1); } }