basic question

A

Altar

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
 
K

kaeli

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
-------------------------------------------------
 
H

Hywel Jenkins

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.
 
E

Evertjan.

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,090
Messages
2,570,603
Members
47,223
Latest member
smithjens316

Latest Threads

Top