|
how do I get the square root of a number?
#349393
12/07/10 00:32
12/07/10 00:32
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
I am trying to make a small program the gives the freq. of a tuned Circuit. I looked in the manual under math and could not find anything about using square root . Thank you renny
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: how do I get the square root of a number?
[Re: Superku]
#349395
12/07/10 01:03
12/07/10 01:03
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
this is what I came up with so far. I dod not have any input code yet.
////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
#define PI 3.14159
int f = 0;
int l = .00000012;
int c = .0000000000020;
/////////////////////////////////////////////////////////////////////
PANEL* panDisplay =
{
digits(35, 10, "f = %0.f", *, 1,f);
digits(35, 28, "l = %0.f", *, 1, l);
digits(35, 38, "c = %0.f", *, 1, c);
flags = SHOW;
}
/////////////////////////////////////////////////////////////////////
function main()
{
screen_size.x = 800;
screen_size.y = 600;
screen_color.blue = 150; // and make its background dark blue
while (1)
{
f = 1/ 2*PI * sqrt(l*c)
wait (1);
}
}
It will not compile and does not give me an error. renny
Last edited by sadsack; 12/07/10 22:04.
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: how do I get the square root of a number?
[Re: sadsack]
#349396
12/07/10 01:11
12/07/10 01:11
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
Uh what are you doing there? var l = .00000012; var c = .0000000000020; var-accuracy ends with .001, you should use double variables. You output the wrong variables (what's a,b?). You have defined PI, not pi. There is no operator between pi and sqrt. Again, what is L? (lite-C is case-sensitive). (Dividing by 1 is not so helpful, but I guess you know that. ) There is no semicolon.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: how do I get the square root of a number?
[Re: Superku]
#349397
12/07/10 01:14
12/07/10 01:14
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
I know, I fixed most of that stuff I going have to do the PI
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: how do I get the square root of a number?
[Re: sadsack]
#349398
12/07/10 01:32
12/07/10 01:32
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
To find the freq of a tuned tank you need to know this l = is the coil in henry c = is the capacitor in farad f = freq
f=2*PI*sqrt*(lc)/1
so let say the l is .00000012 henrys and c is .000000000029 farads very simple, but not so easy when you trying to make the computer do it. renny
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: how do I get the square root of a number?
[Re: sadsack]
#349399
12/07/10 01:36
12/07/10 01:36
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
New code still will not compile????
////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
#define PI 3.14159
int f = 0;
int l = .00000012;
int c = .0000000000020;
/////////////////////////////////////////////////////////////////////
PANEL* panDisplay =
{
digits(35, 10, "f = %0.f", *, 1,f);
digits(35, 28, "l = %0.f", *, 1, l);
digits(35, 38, "c = %0.f", *, 1, c);
flags = SHOW;
}
/////////////////////////////////////////////////////////////////////
function main()
{
screen_size.x = 800;
screen_size.y = 600;
screen_color.blue = 150; // and make its background dark blue
while (1)
{
f = 2*PI * sqrt*(l*c)/1
wait (1);
}
}
Thank you for your help I still don't know what I am doing wrong. renny
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: how do I get the square root of a number?
[Re: sadsack]
#349400
12/07/10 02:08
12/07/10 02:08
|
Joined: Dec 2008
Posts: 1,660 North America
Redeemer
Serious User
|
Serious User
Joined: Dec 2008
Posts: 1,660
North America
|
There are multiple problems with this statement: Starting from the left of the statement: (1) "f" is an int and thus will only record whole numbers (1, 2, 3, 4, etc.) (2) You are not giving any input to the sqrt function, instead you are trying to multiply it by something(?) (3) You have assigned "l" and "c" fractional values, but they are int variables so they have not recorded them. "(l*c)" will produce 0. (4) You are dividing the results of the previous quotient by 1, but dividing *anything* by 1 will yield the original number. x/1 = x (5) There is no semicolon at the end of the line. I think what you mean to write is: You should also change the variable definitions to:
|
|
|
Re: how do I get the square root of a number?
[Re: Redeemer]
#349445
12/07/10 17:06
12/07/10 17:06
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
ok new code, still will not compile. I need to make it compile befor I can start working on the math.
#include <acknex.h>
#include <default.c>
#define PI 3.14159
double f = 0;
double C = .000000000020;
double L = .0000000000020;
/////////////////////////////////////////////////////////////////////
PANEL* panDisplay =
{
digits(35, 10, "f = %0.f", *, 1,f);
digits(35, 28, "l = %0.f", *, 1, l);
digits(35, 38, "c = %0.f", *, 1, c);
flags = SHOW;
}
/////////////////////////////////////////////////////////////////////
function main()
{
screen_size.x = 800;
screen_size.y = 600;
screen_color.blue = 150; // and make its background dark blue
while (1)
{
f = 1/ 2*PI*sqrt(L*C);
wait (1);
}
}
Why will this code not compile? renny
Last edited by sadsack; 12/07/10 19:13.
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|