summaryrefslogtreecommitdiff
path: root/src/classlibnative/bcltype/number.h
blob: 0fd12b11bd9dbacd6a57641adbb030648a07cd4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//
// File: Number.h
//

//

#ifndef _NUMBER_H_
#define _NUMBER_H_

#include <pshpack1.h>

#define NUMBER_MAXDIGITS 50

static const double LOG10V2 = 0.30102999566398119521373889472449;

// DRIFT_FACTOR = 1 - LOG10V2 - epsilon (a small number account for drift of floating point multiplication)
static const double DRIFT_FACTOR = 0.69;

struct NUMBER {
    int precision;
    int scale;
    int sign;
    wchar_t digits[NUMBER_MAXDIGITS + 1];
    wchar_t* allDigits;
    NUMBER() : precision(0), scale(0), sign(0), allDigits(NULL) {}
};

class COMNumber
{
public:
    static FCDECL3_VII(void, DoubleToNumberFC, double value, int precision, NUMBER* number);
    static FCDECL1(double, NumberToDoubleFC, NUMBER* number);
    
    static wchar_t* Int32ToDecChars(__in wchar_t* p, unsigned int value, int digits);
};

#include <poppack.h>

#endif // _NUMBER_H_