1 // natVMFloat.cc - Implementation of java.lang.VMFloat native methods.
2 
3 /* Copyright (C) 1998, 1999, 2001, 2006, 2007  Free Software Foundation
4 
5    This file is part of libgcj.
6 
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9 details.  */
10 
11 #include <config.h>
12 
13 #include <java/lang/Float.h>
14 #include <java/lang/VMFloat.h>
15 #include <jvm.h>
16 
17 union u
18 {
19   jint l;
20   jfloat d;
21 };
22 
23 jint
floatToIntBits(jfloat value)24 java::lang::VMFloat::floatToIntBits(jfloat value)
25 {
26   union u u;
27   u.d = value;
28   jint e = u.l & 0x7f800000;
29   jint f = u.l & 0x007fffff;
30 
31   if (e == 0x7f800000 && f != 0)
32     u.l = 0x7fc00000;
33 
34   return u.l;
35 }
36 
37 jint
floatToRawIntBits(jfloat value)38 java::lang::VMFloat::floatToRawIntBits(jfloat value)
39 {
40   union u u;
41   u.d = value;
42   return u.l;
43 }
44 
45 jfloat
intBitsToFloat(jint bits)46 java::lang::VMFloat::intBitsToFloat(jint bits)
47 {
48   union u u;
49   u.l = bits;
50   return u.d;
51 }
52 
53