Casting int to float


/ Published in: Objective C
Save to your folder(s)

method to convert int to float in ObjC


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.