Search Results

Search found 1 results on 1 pages for 'fishinear'.

Page 1/1 | 1 

  • Prevent printing -0

    - by fishinear
    If I do the following in Objective-C: NSString *result = [NSString stringWithFormat:@"%1.1f", -0.01]; It will give result @"-0.0" Does anybody know how I can force a result @"0.0" (without the "-") in this case? EDIT: I tried using NSNumberFormatter, but it has the same issue. The following also produces @"-0.0": double value = -0.01; NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; [numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; [numberFormatter setMaximumFractionDigits:1]; [numberFormatter setMinimumFractionDigits:1]; NSString *result = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:value]];

    Read the article

1