mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 01:31:08 +00:00
add some more diagnostic info
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39478 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
de8ad5b619
commit
d8a6c9c813
1 changed files with 15 additions and 2 deletions
|
@ -52,9 +52,22 @@ int main()
|
|||
|
||||
s1 = [NSString stringWithFormat: @"%0.3f", 0.0019];
|
||||
n1 = [NSDecimalNumber decimalNumberWithString: @"0.0019"];
|
||||
n2 = [n1 decimalNumberByRoundingAccordingToBehavior: handler];
|
||||
/* Try working with NSDecimal directly
|
||||
*/
|
||||
{
|
||||
NSDecimal result;
|
||||
NSDecimal d1 = [n1 decimalValue];
|
||||
NSString *s2;
|
||||
|
||||
NSLog(@"NSDecimal before rounding %g", NSDecimalDouble(&d1));
|
||||
NSDecimalRound(&result, &d1, [handler scale], [handler roundingMode]);
|
||||
NSLog(@"NSDecimal after rounding %g", NSDecimalDouble(&result));
|
||||
s2 = NSDecimalString(&result, nil);
|
||||
PASS_EQUAL(s2, s1, "NSDecimal rounding 0.0019 to 0.02");
|
||||
n2 = [NSDecimalNumber decimalNumberWithDecimal: result];
|
||||
}
|
||||
s2 = [n2 descriptionWithLocale: nil];
|
||||
PASS_EQUAL(s2, s1, "rounding 0.0019");
|
||||
PASS_EQUAL(s2, s1, "NSDecimalNumber rounding 0.0019");
|
||||
|
||||
END_SET("NSDecimalNumber")
|
||||
|
||||
|
|
Loading…
Reference in a new issue