mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
more
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37627 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
44a8414812
commit
26d1e5545e
1 changed files with 24 additions and 4 deletions
|
@ -28,13 +28,33 @@ int main()
|
|||
n1 = [NSDecimalNumber decimalNumberWithString: @"0.009"];
|
||||
n2 = [n1 decimalNumberByRoundingAccordingToBehavior: handler];
|
||||
s2 = [n2 description];
|
||||
PASS_EQUAL(s1, s2, "rounding 0.009");
|
||||
PASS_EQUAL(s2, s1, "rounding 0.009");
|
||||
|
||||
s1 = [NSString stringWithFormat: @"%0.2f", 0.009];
|
||||
n1 = [NSDecimalNumber decimalNumberWithString: @"0.009"];
|
||||
s1 = [NSString stringWithFormat: @"%0.2f", 0.019];
|
||||
n1 = [NSDecimalNumber decimalNumberWithString: @"0.019"];
|
||||
n2 = [n1 decimalNumberByRoundingAccordingToBehavior: handler];
|
||||
s2 = [n2 description];
|
||||
PASS_EQUAL(s1, s2, "rounding 0.019");
|
||||
PASS_EQUAL(s2, s1, "rounding 0.019");
|
||||
|
||||
handler = [NSDecimalNumberHandler alloc];
|
||||
handler = [[handler initWithRoundingMode: NSRoundPlain
|
||||
scale: 3
|
||||
raiseOnExactness: NO
|
||||
raiseOnOverflow: NO
|
||||
raiseOnUnderflow: NO
|
||||
raiseOnDivideByZero: NO] autorelease];
|
||||
|
||||
s1 = [NSString stringWithFormat: @"%0.3f", 0.0009];
|
||||
n1 = [NSDecimalNumber decimalNumberWithString: @"0.0009"];
|
||||
n2 = [n1 decimalNumberByRoundingAccordingToBehavior: handler];
|
||||
s2 = [n2 description];
|
||||
PASS_EQUAL(s2, s1, "rounding 0.0009");
|
||||
|
||||
s1 = [NSString stringWithFormat: @"%0.3f", 0.0019];
|
||||
n1 = [NSDecimalNumber decimalNumberWithString: @"0.0019"];
|
||||
n2 = [n1 decimalNumberByRoundingAccordingToBehavior: handler];
|
||||
s2 = [n2 description];
|
||||
PASS_EQUAL(s2, s1, "rounding 0.0019");
|
||||
|
||||
END_SET("NSDecimalNumber")
|
||||
|
||||
|
|
Loading…
Reference in a new issue