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