Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
June 24, 2017, 08:41:22 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
  Print  
Author Topic: Having trouble using NSLog with type double  (Read 2028 times)
WorldBuilder
Newbie
*
Posts: 4


« on: January 09, 2012, 04:44:05 PM »

Here is my code:
@autoreleasepool {
        double imaginary1;
       
        NSLog(@"Enter your imaginary number.");
        scanf("%f", &imaginary1);
       
        NSLog(@"Your number is: %f", imaginary1);
        NSLog(@"Program End.");
    }
    return 0;
}

And here is my Output:
Enter your imaginary number.
3.0
Your number is: 0.00000
Program End.


So, what is the proper NSLog char for type double?
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114



« Reply #1 on: January 09, 2012, 06:00:24 PM »

Use %lf for the scanf call, as that's more critical.   You can use that for the NSLog as well.   

Cheers,

Steve
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents ゥ 2009 classroomM.com. All rights reserved.