Posted By

pecta on 07/04/13


Tagged

float convert int casting


Versions (?)

Casting int to float


 / Published in: Objective C
 

method to convert int to float in ObjC

  1. // http://stackoverflow.com/questions/5728998/objective-c-casting-int-to-float
  2.  
  3. // First objective c style
  4.  
  5. int b = 10;
  6. float a = [[NSNumber numberWithInt: b] floatValue]
  7. There will be NSNumber instance and messages numberWithInt, floatValue will be send, right?
  8.  
  9. // Second c style
  10.  
  11. int b = 10;
  12. float a = (float) b;

Report this snippet  

You need to login to post a comment.