Search code examples
objective-cnsstringdoublensscanner

Convert "1.0E-4" from NSString to double


I want to get the double value from "1.04E-4" NSString, but I didn't manage yet how to do it. I tried the following:

1.

NSString* str = @"1.0E-4";
double value = [str doubleValue];  //returns 0.0001

2.

NSString* str = @"1.0E-4";
double value;
NSScanner* scanner = [NSScanner scannerWithString:str];
[scanner scanDouble:&value];
//0.0001 again

Instead of value = 1.0E-4, I get 0.0001

Could someone help me with this?

Appreciate,

Alex.


Solution

  • For the record, 1.0E-4 = 0.0001.