Here you can find the source of valueOfHexDoubleLiteral(char[] source)
Parameter | Description |
---|---|
source | source string containing double precision hexadecimal floating-point literal |
public static double valueOfHexDoubleLiteral(char[] source)
//package com.java2s; /******************************************************************************* * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from ww w. j av a 2s . c o m * IBM Corporation - initial API and implementation *******************************************************************************/ public class Main { /** * Returns the double value corresponding to the given hexadecimal floating-point double precision literal. The literal must be * syntactially correct, and must be a double literal (end in an optional 'd' or 'D'). It must not include either leading or * trailing whitespace or a sign. * <p> * This method returns the same answer as Double.parseDouble(new String(source)) does in JDK 1.5, except that this method throw * NumberFormatException in the case of overflow to infinity or underflow to 0. The method handles all the tricky cases, * including fraction rounding to 53 bits and gradual underflow. * </p> * * @param source * source string containing double precision hexadecimal floating-point literal * @return the double value, including Double.POSITIVE_INFINITY if the non-zero value is too large to be represented, and * Double.NaN if the non-zero value is too small to be represented */ public static double valueOfHexDoubleLiteral(char[] source) { return Double.parseDouble(new String(source)); // TODO use math library to correct parse double value // long bits = convertHexFloatingPointLiteralToBits(source); // return MathUtil.longBitsToDouble(bits); } }