summaryrefslogtreecommitdiff
path: root/packages/cocoaint/src/foundation/NSDecimal.inc
blob: ad3f182dd072b3c5f4400d4d44a52be98821ae0a (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{ Parsed from Foundation.framework NSDecimal.h }
{ Version: 2.1.2 - Wed Dec 8 10:06:43 CET 2010 }


{$ifdef TYPES}
{$ifndef NSDECIMAL_PAS_T}
{$define NSDECIMAL_PAS_T}

{ Constants }

const
  NSRoundPlain = 0;
  NSRoundDown = 1;
  NSRoundUp = 2;
  NSRoundBankers = 3;

const
  NSCalculationNoError = 0;
  NSCalculationLossOfPrecision = 0;
  NSCalculationUnderflow = 1;
  NSCalculationOverflow = 2;
  NSCalculationDivideByZero = 3;

{ Types }
type
  NSRoundingMode = NSUInteger;
  NSRoundingModePtr = ^NSRoundingMode;
  NSCalculationError = NSUInteger;
  NSCalculationErrorPtr = ^NSCalculationError;

{ Defines }
const
  NSDecimalMaxSize = 8;

{$endif}
{$endif}

{$ifdef RECORDS}
{$ifndef NSDECIMAL_PAS_R}
{$define NSDECIMAL_PAS_R}

{ Records }
type
  NSDecimal = record
    _exponent: 0..((1 shl 8)-1);
    _length: 0..((1 shl 4)-1);
    _isNegative: 0..1;
    _isCompact: 0..1;
    _reserved: 0..((1 shl 18)-1);
    _mantissa: cushort;
  end;
NSDecimalPtr = ^NSDecimal;


{$endif}
{$endif}

{$ifdef FUNCTIONS}
{$ifndef NSDECIMAL_PAS_F}
{$define NSDECIMAL_PAS_F}

{ Functions }
procedure NSDecimalCopy(destination: NSDecimalPtr; source: NSDecimalPtr); cdecl; external;
procedure NSDecimalCompact(number: NSDecimalPtr); cdecl; external;
function NSDecimalCompare(leftOperand: NSDecimalPtr; rightOperand: NSDecimalPtr): NSComparisonResult; cdecl; external;
procedure NSDecimalRound(result_: NSDecimalPtr; number: NSDecimalPtr; scale: NSInteger; roundingMode: NSRoundingMode); cdecl; external;
function NSDecimalNormalize(number1: NSDecimalPtr; number2: NSDecimalPtr; roundingMode: NSRoundingMode): NSCalculationError; cdecl; external;
function NSDecimalAdd(result_: NSDecimalPtr; leftOperand: NSDecimalPtr; rightOperand: NSDecimalPtr; roundingMode: NSRoundingMode): NSCalculationError; cdecl; external;
function NSDecimalSubtract(result_: NSDecimalPtr; leftOperand: NSDecimalPtr; rightOperand: NSDecimalPtr; roundingMode: NSRoundingMode): NSCalculationError; cdecl; external;
function NSDecimalMultiply(result_: NSDecimalPtr; leftOperand: NSDecimalPtr; rightOperand: NSDecimalPtr; roundingMode: NSRoundingMode): NSCalculationError; cdecl; external;
function NSDecimalDivide(result_: NSDecimalPtr; leftOperand: NSDecimalPtr; rightOperand: NSDecimalPtr; roundingMode: NSRoundingMode): NSCalculationError; cdecl; external;
function NSDecimalPower(result_: NSDecimalPtr; number: NSDecimalPtr; power: NSUInteger; roundingMode: NSRoundingMode): NSCalculationError; cdecl; external;
function NSDecimalMultiplyByPowerOf10(result_: NSDecimalPtr; number: NSDecimalPtr; power: cshort; roundingMode: NSRoundingMode): NSCalculationError; cdecl; external;
function NSDecimalString(dcm: NSDecimalPtr; locale: id): NSString; cdecl; external;

{$endif}
{$endif}

{$ifdef EXTERNAL_SYMBOLS}
{$ifndef NSDECIMAL_PAS_S}
{$define NSDECIMAL_PAS_S}

{$endif}
{$endif}