basic question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Altar

    basic question

    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

  • kaeli

    #2
    Re: basic question

    In article <bk9pm9$qidcn$1 @ID-135637.news.uni-berlin.de>,
    nomail@hotmail. com enlightened us with...[color=blue]
    > 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 ?
    >[/color]


    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.


    -------------------------------------------------

    Comment

    • Vjekoslav Begovic

      #3
      Re: basic question

      "kaeli" <infinite.possi bilities@NOSPAM att.net> wrote:
      [color=blue]
      > var i = 3;
      > var y = Math.pow(2, i);
      > y will be 6.[/color]

      You mean 8.


      Comment

      • kaeli

        #4
        Re: basic question

        In article <bka5qe$8mc$1@s unce.iskon.hr>, vjbegovic@inet. hr enlightened
        us with...[color=blue]
        > "kaeli" <infinite.possi bilities@NOSPAM att.net> wrote:
        >[color=green]
        > > var i = 3;
        > > var y = Math.pow(2, i);
        > > y will be 6.[/color]
        >
        > You mean 8.[/color]

        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.


        -------------------------------------------------

        Comment

        • Hywel Jenkins

          #5
          Re: basic question

          In article <bk9pm9$qidcn$1 @ID-135637.news.uni-berlin.de>,
          nomail@hotmail. com says...[color=blue]
          > 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;[/color]

          Another reason not to use Visual Basic, then.

          --
          Hywel I do not eat quiche


          Comment

          • Evertjan.

            #6
            Re: basic question

            Altar wrote on 17 sep 2003 in comp.lang.javas cript:
            [color=blue]
            > 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
            >
            >[/color]

            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)

            Comment

            • Dr John Stockton

              #7
              Re: basic question

              JRS: In article <MPG.19d22aa1a0 ca48a9989857@nn tp.lucent.com>, seen in
              news:comp.lang. javascript, kaeli <infinite.possi bilities@NOSPAM att.net>
              posted at Wed, 17 Sep 2003 09:24:36 :-[color=blue]
              >
              >Math.pow(x, n) Returns x to the power of n
              >
              >var i = 3;
              >var y = Math.pow(2, i);
              >y will be 6.[/color]

              8

              --
              © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
              <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
              <URL:http://www.merlyn.demo n.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.

              Comment

              Working...