mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Add support for non-numeric and add test
This commit is contained in:
parent
22fa547084
commit
c5a99a0e40
1 changed files with 16 additions and 9 deletions
|
@ -70,7 +70,7 @@ GS_PRIVATE_INTERNAL(NSByteCountFormatter)
|
|||
{
|
||||
NSByteCountFormatterUnits units = NSByteCountFormatterUseDefault;
|
||||
|
||||
if (byteCount >= KB)
|
||||
if (byteCount >= KB || byteCount == 0.0)
|
||||
{
|
||||
units = NSByteCountFormatterUseKB;
|
||||
}
|
||||
|
@ -161,20 +161,27 @@ GS_PRIVATE_INTERNAL(NSByteCountFormatter)
|
|||
unitName = @"bytes";
|
||||
}
|
||||
|
||||
if(internal->_zeroPadsFractionDigits)
|
||||
if(internal->_allowsNonnumericFormatting && count == 0.0)
|
||||
{
|
||||
outputFormat = [outputFormat stringByAppendingString: @"%01.08f"];
|
||||
outputFormat = [outputFormat stringByAppendingString: @"Zero"];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSInteger whole = (NSInteger)(count / 1);
|
||||
double frac = (double)count - (double)whole;
|
||||
if(frac > 0.0)
|
||||
if(internal->_zeroPadsFractionDigits)
|
||||
{
|
||||
whole += 1;
|
||||
outputFormat = [outputFormat stringByAppendingString: @"%01.08f"];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSInteger whole = (NSInteger)(count / 1);
|
||||
double frac = (double)count - (double)whole;
|
||||
if(frac > 0.0)
|
||||
{
|
||||
whole += 1;
|
||||
}
|
||||
count = (double)whole;
|
||||
outputFormat = [outputFormat stringByAppendingString: @"%01.0f"];
|
||||
}
|
||||
count = (double)whole;
|
||||
outputFormat = [outputFormat stringByAppendingString: @"%01.0f"];
|
||||
}
|
||||
|
||||
if(internal->_includesUnit)
|
||||
|
|
Loading…
Reference in a new issue