Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / metadata / number-ms.h
1 /**
2  * \file
3  */
4
5 #ifndef __MONO_NUMBER_MS_H__
6 #define __MONO_NUMBER_MS_H__
7
8 #include <glib.h>
9
10 // Double floating point Bias
11 #define MONO_DOUBLE_BIAS 1022
12
13 // Structure to access an encoded double floating point
14 typedef struct {
15 #if G_BYTE_ORDER == G_BIG_ENDIAN
16         guint sign   : 1;
17         guint exp    : 11;
18         guint mantHi : 20;
19         guint mantLo : 32;
20 #else // BIGENDIAN
21         guint mantLo : 32;
22         guint mantHi : 20;
23         guint exp    : 11;
24         guint sign   : 1;
25 #endif
26 } MonoDouble;
27
28 typedef union {
29         MonoDouble s;
30         gdouble d;
31 } MonoDouble_double;
32
33 // Single floating point Bias
34 #define MONO_SINGLE_BIAS 126
35
36 // Structure to access an encoded single floating point
37 typedef struct {
38 #if G_BYTE_ORDER == G_BIG_ENDIAN
39         guint sign : 1;
40         guint exp  : 8;
41         guint mant : 23;
42 #else
43         guint mant : 23;
44         guint exp  : 8;
45         guint sign : 1;
46 #endif
47 } MonoSingle;
48
49 typedef union {
50         MonoSingle s;
51         gfloat f;
52 } MonoSingle_float;
53
54 #define MONO_NUMBER_MAXDIGITS 50
55
56 typedef struct  {
57         gint32 precision;
58         gint32 scale;
59         gint32 sign;
60         guint16 digits [MONO_NUMBER_MAXDIGITS + 1];
61         guint16 *allDigits;
62 } MonoNumber;
63
64 gint
65 mono_double_from_number (gpointer from, MonoDouble *target);
66
67 #endif