mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
fix for NSDecimalNumber rounding precision by Pirmin Braun <pb@intars.de>
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37628 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
79188f282f
commit
71f114887d
2 changed files with 20 additions and 1 deletions
|
@ -1,3 +1,7 @@
|
|||
2014-01-21 Pirmin Braun <pb@intars.de>
|
||||
|
||||
* Source/NSDecimal.m: Fix for rounding precision.
|
||||
|
||||
2014-01-20 Quentin Mathe <quentin.mathe@gmail.com>
|
||||
|
||||
* Source/NSSet.m: Added missing ([-valueForKey:]) method.
|
||||
|
|
|
@ -264,7 +264,7 @@ GSDecimalRound(GSDecimal *result, int scale, NSRoundingMode mode)
|
|||
|
||||
if (result->length <= l)
|
||||
return;
|
||||
else if (l <= 0)
|
||||
else if (l < 0)
|
||||
{
|
||||
result->length = 0;
|
||||
result->exponent = 0;
|
||||
|
@ -276,6 +276,21 @@ GSDecimalRound(GSDecimal *result, int scale, NSRoundingMode mode)
|
|||
int c, n;
|
||||
BOOL up;
|
||||
|
||||
if (l == 0)
|
||||
{
|
||||
int x;
|
||||
|
||||
x = result->length;
|
||||
result->length += 1;
|
||||
l += 1;
|
||||
while (x > 0)
|
||||
{
|
||||
result->cMantissa[x] = result->cMantissa[x-1];
|
||||
x--;
|
||||
}
|
||||
result->cMantissa[0] = 0;
|
||||
}
|
||||
|
||||
// Adjust length and exponent
|
||||
result->exponent += result->length - l;
|
||||
result->length = l;
|
||||
|
|
Loading…
Reference in a new issue