float value changes when passed to function
I am using cocos2d. While debugging an issue I discovered it was caused by the following:
cocos2d code:
check elapsed time for the tick event. If > whatever call my selector and pass time
Time is stored as a cctime which is typedef from a float
In my selector i also accept a cctime.
When I am stepping through the cocos code I see an expected value for time. When it calls my selector I see a value for time like 0.31231323x10^30
Anyone know why a selector with the same variable type might do this?
cocos2d code:
check elapsed time for the tick event. If > whatever call my selector and pass time
Time is stored as a cctime which is typedef from a float
In my selector i also accept a cctime.
When I am stepping through the cocos code I see an expected value for time. When it calls my selector I see a value for time like 0.31231323x10^30
Anyone know why a selector with the same variable type might do this?
Further investigation shows even stranger stuff going on here...
First it won't even stop at a breakpoint on the delta= line
2nd if i stop at the levelPass line and inspect delta its value is various things but nothing anywhere close to what I just set it to... The print outs show:
Delta before 0.000000
Delta after 0.001000
Something funky this way comes...
Code:
-(void) step: (ccTime) delta
{
printf("Delta before %f\n",delta);
delta=0.001f;
printf("Delta after %f\n",delta);
levelPassTime(level,delta);First it won't even stop at a breakpoint on the delta= line
2nd if i stop at the levelPass line and inspect delta its value is various things but nothing anywhere close to what I just set it to... The print outs show:
Delta before 0.000000
Delta after 0.001000
Something funky this way comes...
kendric Wrote:Further investigation shows even stranger stuff going on here...
Code:
-(void) step: (ccTime) delta
{
printf("Delta before %f\n",delta);
delta=0.001f;
printf("Delta after %f\n",delta);
levelPassTime(level,delta);
First it won't even stop at a breakpoint on the delta= line
2nd if i stop at the levelPass line and inspect delta its value is various things but nothing anywhere close to what I just set it to... The print outs show:
Delta before 0.000000
Delta after 0.001000
Something funky this way comes...
Not quite. Something funky this way came.
http://www.cocos2d-iphone.org/forum/topic/2426
Try casting it to a float; perhaps you'll solve the problem?
I think its due to some sort of assembled code and what I see being out of sync. WHen I run the same thing with it on the device instead of simulator its fine.
I suspect it's due to you calling a function or method without a prototype. That'll happen to work on the device, and not on the simulator.
Use the warning settings from this page: http://www.idevgames.com/irc and fix the resulting errors.
Use the warning settings from this page: http://www.idevgames.com/irc and fix the resulting errors.
I figured this out. I had it set to release mode and I wasn't debugging the code I thought I was because I guess for release mode it compiles things into more efficient blocks.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Float vs Double | bwalters | 24 | 9,138 |
Jan 3, 2006 03:49 PM Last Post: DoG |
|

