Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
finding square route with javascript???
Old 09-15-2005, 06:15 PM finding square route with javascript???
hiptobesquare's Avatar
Extreme Talker

Posts: 186
Location: London UK
Trades: 0
Hi.
i have an interesting project writing a script that can calculate the angles and lengths required when cutting frame for use on sliding wardrobe doors with angled top corners (to accomodate sloping ceilings). My question: I know that to work out the hypotenuse of a triangle i add both sides together squared- then find the square root of the resulting figure. My problem is finding the square root of a number using javascript. Has anyone ever seen such a function???
hiptobesquare is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-15-2005, 06:17 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Code:
Math.sqrt(number)
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 09-15-2005, 07:00 PM
hiptobesquare's Avatar
Extreme Talker

Posts: 186
Location: London UK
Trades: 0
Oh i didnt know that. i just figured this out though
[javascript]
var z = 100;

$i=0;
while (i * i != z ){
i++;
}
[/javascript]
it will only work if var z has a whole number for square route but all the numbers i wouldv been working with did have.

I think il use your way anyway Oberon it looks to others like i know more JS then.
Thanks for helping out on another of my simple problems
hiptobesquare is offline
Reply With Quote
View Public Profile
 
Old 09-15-2005, 07:08 PM
hiptobesquare's Avatar
Extreme Talker

Posts: 186
Location: London UK
Trades: 0
1000 posts. congratulations
hiptobesquare is offline
Reply With Quote
View Public Profile
 
Old 09-15-2005, 08:13 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Yeah I know I made a celebratory post in the general forum...

I know next to no javascript, I just googled for 'javascript square root' and this came up. If you can raise numbers to powers you can get a square root by 'raising' something to the power of 0.5 also.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 02-21-2007, 08:26 AM Re: finding square route with javascript???
Novice Talker

Posts: 5
Name: David Kilpatrick
Trades: 0
How do u do power of a number in javascript
I am trying to do a script to calculate runway requirements and second of acceleration on a aircraft

like this
distance=1/2 * 8 (ft/sec) * t(secs)

How would u do that in javascript
Can some one HELP ME PLEASE
Thanks People

Quote:
Originally Posted by 0beron View Post
Yeah I know I made a celebratory post in the general forum...

I know next to no javascript, I just googled for 'javascript square root' and this came up. If you can raise numbers to powers you can get a square root by 'raising' something to the power of 0.5 also.
delta is offline
Reply With Quote
View Public Profile
 
Old 02-21-2007, 10:02 AM Re: finding square route with javascript???
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
Quote:
Originally Posted by delta View Post
How do u do power of a number in javascript
I am trying to do a script to calculate runway requirements and second of acceleration on a aircraft

like this
distance=1/2 * 8 (ft/sec) * t(secs)

How would u do that in javascript
Can some one HELP ME PLEASE
Thanks People
Math.pow(number,power);

see:
http://www.w3schools.com/jsref/jsref_obj_math.asp
willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 02-21-2007, 12:05 PM Re: finding square route with javascript???
Novice Talker

Posts: 5
Name: David Kilpatrick
Trades: 0
This is my code and it is blank in IE6 and firefox !
Where am I going wrong here ?

<html><head><title>Math and javascript</title></head>
<Body>
<table><tr><td>
<script language=javascript>
for (x=0;x<45;x++)
document.write "table 1"
document.write x
</script>
</td>
<td>
<script language=javascript>
document.write "table 2"
document.write (.5*8*Math.pow(x,2)+"<br>")
</script>
</td></tr></table>
</body></html>
delta is offline
Reply With Quote
View Public Profile
 
Old 02-22-2007, 03:20 PM Re: finding square route with javascript???
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
Quote:
Originally Posted by delta View Post
Where am I going wrong here ?
What is the objective?
willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 02-23-2007, 06:14 PM Re: finding square route with javascript???
Novice Talker

Posts: 5
Name: David Kilpatrick
Trades: 0
Quote:
Originally Posted by willcode4beer View Post
What is the objective?
Thanks I was able to work it out willcode4beer !
The objective was to calculate (distance = 1/2* g * t ^2 )
Thanks willcode4beer
PS: This is a great site !
delta is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to finding square route with javascript???
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.37088 seconds with 12 queries