2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mono / metadata / decimal.h
1 #include "mono/metadata/object.h"
2
3 /* representation for C# type decimal */
4 /* This is the layout of MSC */
5 typedef struct
6 {
7         union {
8                 guint32 ss32;
9 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
10             struct {
11                     unsigned int sign      : 1;
12                     unsigned int reserved2 : 7;
13                     unsigned int scale     : 8;
14                     unsigned int reserved1 : 16;
15             } signscale;
16 #else
17             struct {
18                     unsigned int reserved1 : 16;
19                     unsigned int scale     : 8;
20                     unsigned int reserved2 : 7;
21                     unsigned int sign      : 1;
22             } signscale;
23 #endif
24         } u;
25     guint32 hi32;
26     guint32 lo32;
27     guint32 mid32;
28 } decimal_repr;
29
30
31 /* function prototypes */
32 gint32 mono_decimalIncr(/*[In, Out]*/decimal_repr* pA, /*[In]*/decimal_repr* pB);
33 gint32 mono_double2decimal(/*[Out]*/decimal_repr* pA, double val, gint32 digits);
34 gint32 mono_decimal2UInt64(/*[In]*/decimal_repr* pD, guint64* pResult);
35 gint32 mono_decimal2Int64(/*[In]*/decimal_repr* pD, gint64* pResult);
36 void mono_decimalFloorAndTrunc(/*[In, Out]*/decimal_repr* pD, gint32 floorFlag);
37 void mono_decimalRound(/*[In, Out]*/decimal_repr* pD, gint32 decimals);
38 gint32 mono_decimalMult(/*[In, Out]*/decimal_repr* pA, /*[In]*/decimal_repr* pB);
39 gint32 mono_decimalDiv(/*[Out]*/decimal_repr* pC, /*[In]*/decimal_repr* pA, /*[In]*/decimal_repr* pB);
40 gint32 mono_decimalIntDiv(/*[Out]*/decimal_repr* pC, /*[In]*/decimal_repr* pA, /*[In]*/decimal_repr* pB);
41 gint32 mono_decimalCompare(/*[In]*/decimal_repr* pA, /*[In]*/decimal_repr* pB);
42 double mono_decimal2double(/*[In]*/decimal_repr* pA);
43 gint32 mono_decimalSetExponent(/*[In, Out]*/decimal_repr* pA, gint32 texp);
44
45 gint32 mono_string2decimal(/*[Out]*/decimal_repr* pA, /*[In]*/MonoString* s, gint32 decrDecimal, gint32 sign);
46 gint32 mono_decimal2string(/*[In]*/decimal_repr* pA, int digits, int decimals,
47                          /*[Out]*/MonoArray* pArray, gint32 bufSize, gint32* pDecPos, gint32* pSign);
48