Suppose we have
float x = 24.0;
I want to do the following:
// hexRepresentation is of format HxHHHHHHHH
// where H is a hexadecimal symbol 0-9 or a-f
NSString *hexRepresentation = [self hexadecimalFromFloat:x];
Please help me complete the following method:
- (NSString *)hexadecimalFromFloat:(float)flt {
NSString *h;
/*
What should I do here to convert the float
value into its HxHHHHHHHH format? Then what
should I do to ensure it's converted into a
proper NSString and assigned to h?
*/
return h;
}
Rough, untested code:
This may or may not be in IEEE-754 notation, etc etc. It also assumes
sizeof(float) == sizeof(int) == 4