Mercurial > projects > dstep
comparison dstep/foundation/NSDecimal.d @ 14:89f3c3ef1fd2
Added the Foundation framework
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:23:15 +0200 |
parents | |
children | 19885b43130e |
comparison
equal
deleted
inserted
replaced
13:4f583f7e242e | 14:89f3c3ef1fd2 |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Aug 3, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.foundation.NSDecimal; | |
8 | |
9 import dstep.foundation.NSDictionary; | |
10 import dstep.foundation.NSObjCRuntime; | |
11 import dstep.limits; | |
12 import dstep.objc.bridge.Bridge; | |
13 import dstep.objc.objc : id; | |
14 | |
15 alias NSUInteger NSRoundingMode; | |
16 alias NSUInteger NSCalculationError; | |
17 | |
18 enum | |
19 { | |
20 NSRoundPlain, | |
21 NSRoundDown, | |
22 NSRoundUp, | |
23 NSRoundBankers | |
24 } | |
25 | |
26 enum | |
27 { | |
28 NSCalculationNoError = 0, | |
29 NSCalculationLossOfPrecision, | |
30 NSCalculationUnderflow, | |
31 NSCalculationOverflow, | |
32 NSCalculationDivideByZero | |
33 } | |
34 | |
35 struct NSDecimal | |
36 { | |
37 int _exponent; | |
38 uint _length; | |
39 uint _isNegative; | |
40 uint _isCompact; | |
41 uint _reserved; | |
42 unsigned short* _mantissa; | |
43 } | |
44 | |
45 NSString NSDecimalString (NSDecimal* dcm, Object locale) | |
46 { | |
47 return Bridge.invokeObjcFunction!(NSString, bindings.NSDecimalString, NSDecimal*, Object)(dcm, locale); | |
48 } | |
49 | |
50 extern (C) | |
51 { | |
52 void NSDecimalCopy (NSDecimal* destination, NSDecimal* source); | |
53 void NSDecimalCompact (NSDecimal* number); | |
54 int NSDecimalCompare (NSDecimal* leftOperand, NSDecimal* rightOperand); | |
55 void NSDecimalRound (NSDecimal* result, NSDecimal* number, NSInteger scale, uint roundingMode); | |
56 uint NSDecimalNormalize (NSDecimal* number1, NSDecimal* number2, uint roundingMode); | |
57 uint NSDecimalAdd (NSDecimal* result, NSDecimal* leftOperand, NSDecimal* rightOperand, uint roundingMode); | |
58 uint NSDecimalSubtract (NSDecimal* result, NSDecimal* leftOperand, NSDecimal* rightOperand, uint roundingMode); | |
59 uint NSDecimalMultiply (NSDecimal* result, NSDecimal* leftOperand, NSDecimal* rightOperand, uint roundingMode); | |
60 uint NSDecimalDivide (NSDecimal* result, NSDecimal* leftOperand, NSDecimal* rightOperand, uint roundingMode); | |
61 uint NSDecimalPower (NSDecimal* result, NSDecimal* number, NSUInteger power, uint roundingMode); | |
62 uint NSDecimalMultiplyByPowerOf10 (NSDecimal* result, NSDecimal* number, short power, uint roundingMode); | |
63 } |