Merge from mainline
[official-gcc.git] / libjava / java / lang / natFloat.cc
blobf090b815e26557edb53164df0360f7a3f269efb1
1 // natFloat.cc - Implementation of java.lang.VMFloat native methods.
3 /* Copyright (C) 1998, 1999, 2001, 2006 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9 details. */
11 #include <config.h>
13 #include <java/lang/Float.h>
14 #include <java/lang/VMFloat.h>
15 #include <jvm.h>
17 union u
19 jint l;
20 jfloat d;
23 jint
24 java::lang::VMFloat::floatToIntBits(jfloat value)
26 union u u;
27 u.d = value;
28 jint e = u.l & 0x7f800000;
29 jint f = u.l & 0x007fffff;
31 if (e == 0x7f800000 && f != 0)
32 u.l = 0x7fc00000;
34 return u.l;
37 jint
38 java::lang::VMFloat::floatToRawIntBits(jfloat value)
40 union u u;
41 u.d = value;
42 return u.l;
45 jfloat
46 java::lang::VMFloat::intBitsToFloat(jint bits)
48 union u u;
49 u.l = bits;
50 return u.d;