December 2012
Beginner
552 pages
12h 58m
English
To effectively develop Objective-C programs, you must understand the rules used for the implicit conversion of floating-point and integer values in Objective-C. Program 4.5 demonstrates some of the simple conversions between numeric data types.
Program 4.5.
// Basic conversions in Objective-C#import <Foundation/Foundation.h>int main (int argc, char * argv[]){ @autoreleasepool { float f1 = 123.125, f2; int i1, i2 = -150; i1 = f1; // floating to integer conversion NSLog (@"%f assigned to an int produces %i", f1, i1); f1 = i2; // integer to floating conversion NSLog (@"%i assigned to a float produces %f", i2, f1); f1 = i2 / 100; // integer divided by integer
Read now
Unlock full access