1

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.

Alexandru Circus
  • 5,478
  • 7
  • 52
  • 89

2 Answers2

6

For the record, 1.0E-4 = 0.0001.

Alexsander Akers
  • 15,967
  • 12
  • 58
  • 83
  • System.out.println(""+Double.parseDouble("1.0E-4")) will retun in Java 1.0E-4, but in objc 0.0001.The idea is that I want to translate some classes from Java into objc and to keep their functionality, but I encounter difficulties and this could be one of those – Alexandru Circus Jan 13 '11 at 18:25
0

In Java, if I use Double.parseDouble("1.0E-4") I get 1.0E-4, but in objc I don't know how to do this.I encounter some problems translating some Java code into objc, and this is one of the differences that I've spot since now.

Alexandru Circus
  • 5,478
  • 7
  • 52
  • 89