Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / metadata / decimal-ms.h
1 /**
2  * \file
3  */
4
5 #ifndef __MONO_DECIMAL_MS_H__
6 #define __MONO_DECIMAL_MS_H__
7
8 typedef struct {
9     // Decimal.cs treats the first two shorts as one long
10     // And they seriable the data so we need to little endian
11     // seriliazation
12     // The wReserved overlaps with Variant's vt member
13 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
14     union {
15         struct {
16             uint8_t sign;
17             uint8_t scale;
18         } u;
19         uint16_t signscale;
20     } u;
21     uint16_t reserved;
22 #else
23     uint16_t reserved;
24     union {
25         struct {
26             uint8_t scale;
27             uint8_t sign;
28         } u;
29         uint16_t signscale;
30     } u;
31 #endif
32     uint32_t Hi32;
33     union {
34         struct {
35             uint32_t Lo32;
36             uint32_t Mid32;
37         } v;
38         uint64_t Lo64;
39     } v;
40 } MonoDecimal;
41
42 typedef enum {
43         MONO_DECIMAL_CMP_LT=-1,
44         MONO_DECIMAL_CMP_EQ,
45         MONO_DECIMAL_CMP_GT
46 } MonoDecimalCompareResult;
47         
48 MonoDecimalCompareResult
49         mono_decimal_compare (MonoDecimal *left, MonoDecimal *right);
50
51 void    mono_decimal_init_single   (MonoDecimal *_this, float value);
52 void    mono_decimal_init_double   (MonoDecimal *_this, double value);
53 void    mono_decimal_floor         (MonoDecimal *d);
54 int32_t mono_decimal_get_hash_code (MonoDecimal *d);
55 void    mono_decimal_multiply      (MonoDecimal *d1, MonoDecimal *d2);
56 void    mono_decimal_round         (MonoDecimal *d, int32_t decimals);
57 void    mono_decimal_tocurrency    (MonoDecimal *decimal);
58 double  mono_decimal_to_double     (MonoDecimal d);
59 int32_t mono_decimal_to_int32      (MonoDecimal d);
60 float   mono_decimal_to_float      (MonoDecimal d);
61 void    mono_decimal_truncate      (MonoDecimal *d);
62 void    mono_decimal_addsub        (MonoDecimal *left, MonoDecimal *right, uint8_t sign);
63 void    mono_decimal_divide        (MonoDecimal *left, MonoDecimal *right);
64 int     mono_decimal_from_number   (void *from, MonoDecimal *target);
65
66 #endif