Table of Contents

floatValue

 
- (float)floatValue;
 

Returns the receiver’s value.

Return Value - The receiver’s value as datatyp, converting it as necessary.

ObjC Sourcecode Example

    //** Sample Datatype **
    float myFloat = 1.123456f;
 
    //** Initializing NSNumber Object **
    NSNumber *myFloatNumber = [[NSNumber alloc]initWithFloat:myFloat];
 
    //**  To access your value use floatValue **
    if ([myFloatNumber floatValue] == 1.123456f) {
 
        NSLog(@"myFloatNumber:%@", myFloatNumber);
        NSLog(@"myFloat: %f", [myFloatNumber floatValue]);
 
    }

Output for this example code

2012-07-01 15:23:05.981 NSNumberSample[402:f803] myFloatNumber:1.123456
2012-07-01 15:23:05.983 NSNumberSample[402:f803] myFloat: 1.123456