By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,610 Members | 1,923 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,610 IT Pros & Developers. It's quick & easy.

basic question

P: n/a
Hi

In Visual Basic I have this numeric expression :

x = 2 ^ i;

if i = 3 the result for x would be 2 * 2 * 2 = 6;

is there any equivalent in javascript for the "^" arithmetic operator ?

thanks in advance

Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
In article <bk************@ID-135637.news.uni-berlin.de>,
no****@hotmail.com enlightened us with...
Hi

In Visual Basic I have this numeric expression :

x = 2 ^ i;

if i = 3 the result for x would be 2 * 2 * 2 = 6;

is there any equivalent in javascript for the "^" arithmetic operator ?

Math.pow(x, n) Returns x to the power of n

var i = 3;
var y = Math.pow(2, i);
y will be 6.

-------------------------------------------------
~kaeli~
Hey, if you got it flaunt it! If you don't, stare
at someone who does. Just don't lick the TV screen,
it leaves streaks.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #2

P: n/a
"kaeli" <in********************@NOSPAMatt.net> wrote:
var i = 3;
var y = Math.pow(2, i);
y will be 6.


You mean 8.
Jul 20 '05 #3

P: n/a
In article <bk**********@sunce.iskon.hr>, vj*******@inet.hr enlightened
us with...
"kaeli" <in********************@NOSPAMatt.net> wrote:
var i = 3;
var y = Math.pow(2, i);
y will be 6.


You mean 8.


I'm sleeping today. :)
-------------------------------------------------
~kaeli~
Hey, if you got it flaunt it! If you don't, stare
at someone who does. Just don't lick the TV screen,
it leaves streaks.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #4

P: n/a
In article <bk************@ID-135637.news.uni-berlin.de>,
no****@hotmail.com says...
Hi

In Visual Basic I have this numeric expression :

x = 2 ^ i;

if i = 3 the result for x would be 2 * 2 * 2 = 6;


Another reason not to use Visual Basic, then.

--
Hywel I do not eat quiche
http://hyweljenkins.co.uk/
http://hyweljenkins.co.uk/mfaq.php
Jul 20 '05 #5

P: n/a
Altar wrote on 17 sep 2003 in comp.lang.javascript:
Hi

In Visual Basic I have this numeric expression :

x = 2 ^ i;

if i = 3 the result for x would be 2 * 2 * 2 = 6;

is there any equivalent in javascript for the "^" arithmetic operator ?

thanks in advance


pow Method
This method returns the value of x to the power of y, where x is the base,
and y is the exponent.

result = Math.pow(x, y)
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #6

P: n/a
JRS: In article <MP************************@nntp.lucent.com>, seen in
news:comp.lang.javascript, kaeli <in********************@NOSPAMatt.net>
posted at Wed, 17 Sep 2003 09:24:36 :-

Math.pow(x, n) Returns x to the power of n

var i = 3;
var y = Math.pow(2, i);
y will be 6.


8

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> RAH Prins : c.l.p.b mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.