Go to Post Someone once said, "I know what finished is, and I know what a robot is, but what is this finished robot you speak of?" - EricH [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 08-02-2007, 17:14
flippo flippo is offline
Registered User
FRC #1701
 
Join Date: Nov 2006
Location: Detroit, MI
Posts: 2
flippo is an unknown quantity at this point
Question Floating point math zero

I searched through the forum and could not find a similar topic, so:

I have timed my code and determined that I can use floating point math, however when I attempt to use the standard library:

float sqrt(float);

function it returns "zero" (the actual zero value not random numbers) randomly when my input is at a constant value. I am also recieving similar problems from other floating point trig functions. Can anyone help, or has anyone experienced similar problems?

Here is the actual function that is calling the sqrt function.

Quote:
void handleDriveJoystick(void) {
unsigned int radius;
signed int prettyJoyX, prettyJoyY;

//take care of the joysticks
prettyJoyX = (signed int)DRIVER_JOY_X - 127;
prettyJoyY = (signed int)DRIVER_JOY_Y - 127;

if (DRIVER_JOY_X == 127 && DRIVER_JOY_Y == 127)
theta = 0.;

else
theta = atan2((float)prettyJoyX, (float)prettyJoyY);

radius = (int) (10.0 * sqrt((float)(prettyJoyX*prettyJoyX + prettyJoyY*prettyJoyY)));

[...]

printf("Joy_Y: %u Radius %u ", p1_y, radius);
The omitted code does not reference radius at any point.

Thank you for any and all help.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Floating point math in PBASIC John Gutmann Programming 2 26-12-2005 20:07
Converting floating point to integers logicalhippo Programming 3 29-01-2005 12:10
OI and analog: Zero value Astronouth7303 Programming 1 02-02-2004 16:00
Community Zero archiver 2001 1 24-06-2002 04:08
Zero Hour archiver 2000 4 23-06-2002 21:59


All times are GMT -5. The time now is 17:31.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi