How to find out the format of a float?
Posted
by cannyboy
on Stack Overflow
See other posts from Stack Overflow
or by cannyboy
Published on 2010-06-08T16:30:43Z
Indexed on
2010/06/08
16:32 UTC
Read the original article
Hit count: 130
I'm working with someone else's code, and there is a float with some unusual qualities.
If I output the float using:
NSLog(@"theFloat: %f", record.theFloat);
I get:
theFloat: 0.000000
However, if I use:
NSLog(@"(int)theFloat = %i", (int) record.theFloat);
I get:
(int)theFloat: 71411232
How do I discover the real format and value of theFloat? I know that it should contain a large number.
Incidentally, the Record class which contains the float propertizes it in such a way:
@property (assign) float* theFloat;
There is also floatLength:
@property (assign) int floatLength;
And has this method, which seems to indicate that the float is of variable length (?):
- (void) copyFloat:(float*)theF ofLength:(int)len
{
float *floatcopy = malloc(len*sizeof(float));
memcpy(floatcopy, theF, len*sizeof(float));
self.theFloat = floatcopy;
}
© Stack Overflow or respective owner