Path: blob/master/src/java.base/share/native/libjava/Double.c
41149 views
/*1* Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#include "jni.h"26#include "jni_util.h"27#include "jlong.h"28#include "jvm.h"2930#include "java_lang_Double.h"3132/*33* Find the double float corresponding to a given bit pattern34*/35JNIEXPORT jdouble JNICALL36Java_java_lang_Double_longBitsToDouble(JNIEnv *env, jclass unused, jlong v)37{38union {39jlong l;40double d;41} u;42jlong_to_jdouble_bits(&v);43u.l = v;44return (jdouble)u.d;45}4647/*48* Find the bit pattern corresponding to a given double float, NOT collapsing NaNs49*/50JNIEXPORT jlong JNICALL51Java_java_lang_Double_doubleToRawLongBits(JNIEnv *env, jclass unused, jdouble v)52{53union {54jlong l;55double d;56} u;57jdouble_to_jlong_bits(&v);58u.d = (double)v;59return u.l;60}616263