Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, 7th_zorro, dr_panther), 1,297 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
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 Offline OP
Senior Member
sadsack  Offline 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: sadsack] #349394
12/07/10 00:38
12/07/10 00:38
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
sqrt(x)


"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] #349395
12/07/10 01:03
12/07/10 01:03
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline 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.

Code:
////////////////////////////////////////////////////////////////////
#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 Offline
Senior Expert
Superku  Offline
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?).

Code:
f = 2*pi sqrt(L*c)/1



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. wink )
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 Offline OP
Senior Member
sadsack  Offline 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 Offline OP
Senior Member
sadsack  Offline 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 Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
New code still will not compile????


Code:
////////////////////////////////////////////////////////////////////
#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 Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
There are multiple problems with this statement:
Code:
f = 2*PI * sqrt*(l*c)/1



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:
Code:
f = 2*PI * sqrt(l*c);



You should also change the variable definitions to:
Code:
double f, c, l;




Eats commas for breakfast.

Play Barony: Cursed Edition!
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 Offline OP
Senior Member
sadsack  Offline 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.


Code:
#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

Re: how do I get the square root of a number? [Re: sadsack] #349448
12/07/10 18:37
12/07/10 18:37
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Lite-C is case sensetive!

l != L

Page 1 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1