Go to Post PRY BAR: A tool used to crumple the metal surrounding that clip or bracket you needed to remove in order to replace a 50 cent part. - dlavery [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

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 15-02-2009, 10:15
tekman1001 tekman1001 is offline
Registered User
FRC #2342
 
Join Date: Jan 2009
Location: New Hampshire
Posts: 11
tekman1001 is an unknown quantity at this point
Crio Square Roots

Hi our crio is giving us errors when we try to do square roots using sqrt(variable)
Where variable is obviously a variable. any help would be usefully and appreciated.
  #2   Spotlight this post!  
Unread 15-02-2009, 10:18
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: Crio Square Roots

Quote:
Originally Posted by tekman1001 View Post
Hi our crio is giving us errors when we try to do square roots using sqrt(variable)
Where variable is obviously a variable. any help would be usefully and appreciated.
We're going to need a bit more info to help you out here.

What errors are you getting? What does your code look like?
  #3   Spotlight this post!  
Unread 15-02-2009, 10:23
tekman1001 tekman1001 is offline
Registered User
FRC #2342
 
Join Date: Jan 2009
Location: New Hampshire
Posts: 11
tekman1001 is an unknown quantity at this point
Re: Crio Square Roots

When we try to download to the crio it tells us it cannot find the function. The code looks like this "Kvar = Dvar / sqrt(PrecentVar);"
  #4   Spotlight this post!  
Unread 15-02-2009, 11:18
Sentient's Avatar
Sentient Sentient is offline
Registered User
FRC #0639 (Code Red)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Ithaca
Posts: 21
Sentient is on a distinguished road
Re: Crio Square Roots

It may be that WPILib doesn't have a sqrt function. I honestly don't know what WPILib has implemented, but sqrt() is usually in "math.h", which is a Windows Library (or whatever OS you are using).
  #5   Spotlight this post!  
Unread 15-02-2009, 11:32
tdlrali tdlrali is offline
Registered User
FRC #0469 (Las Guerrillas)
Team Role: Programmer
 
Join Date: Sep 2006
Rookie Year: 2006
Location: MI
Posts: 377
tdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud of
Re: Crio Square Roots

Second sentinel, make sure you #include <cmath>
  #6   Spotlight this post!  
Unread 15-02-2009, 12:40
bronxbomber92 bronxbomber92 is offline
Registered User
FRC #1551 (Grapes of Wrath)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Naples
Posts: 75
bronxbomber92 is an unknown quantity at this point
Re: Crio Square Roots

If for some reason you're having problems beyond #included <cmath> (in which case, you should probably fix anyways :-P) here's a nice implementation of sqrt for floats taken from quake:

Code:
float SquareRootFloat(float number) {
    long i;
    float x, y;
    const float f = 1.5F;

    x = number * 0.5F;
    y  = number;
    i  = * ( long * ) &y;
    i  = 0x5f3759df - ( i >> 1 );
    y  = * ( float * ) &i;
    y  = y * ( f - ( x * y * y ) );
    y  = y * ( f - ( x * y * y ) );
    return number * y;
}
Closed Thread


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
[FVC]: Return to the roots? Lil' Lavery FIRST Tech Challenge 1 26-06-2007 14:34
Square PBC Tubing ThomasP Technical Discussion 1 12-01-2007 11:08
Square Wheels? mechanicalbrain Technical Discussion 11 08-01-2006 17:34
Square Root bludstayne Programming 3 14-02-2004 14:48
Square Rack Sketch archiver 2000 1 24-06-2002 00:09


All times are GMT -5. The time now is 01:09.

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