View Full Version : Javascript square root

1337coder

12-12-2006, 08:41 PM

Sorry, I'm still a novice at Javascript. I cannot manage to do a square root operation. I am using the coding:

var a = Math.sqrt(b);

Anyhelp would be appreciated. Thanks.

david_kw

12-12-2006, 10:35 PM

Looks fine to me as long as b is an integer. Try just typing

alert(Math.sqrt(9));

and see if it returns 3 to cut out the guesswork

david_kw

1337coder

12-13-2006, 01:58 AM

For some reason, putting it into an alert worked, and it also worked with a variable. Thanks a lot, David

dwees

12-13-2006, 06:43 AM

b definitely does not have to be an integer, it can be any real number (ie loads of decimal places will work).

Dave

Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.