Excel “power of” function to JS












2















Any help converting Excel "power of" function to JavaScript?



Values are:



A1 = 99%

A2 = 45



formula is = (A1^A2)*100
results rounded to whole number is 64.










share|improve this question



























    2















    Any help converting Excel "power of" function to JavaScript?



    Values are:



    A1 = 99%

    A2 = 45



    formula is = (A1^A2)*100
    results rounded to whole number is 64.










    share|improve this question

























      2












      2








      2








      Any help converting Excel "power of" function to JavaScript?



      Values are:



      A1 = 99%

      A2 = 45



      formula is = (A1^A2)*100
      results rounded to whole number is 64.










      share|improve this question














      Any help converting Excel "power of" function to JavaScript?



      Values are:



      A1 = 99%

      A2 = 45



      formula is = (A1^A2)*100
      results rounded to whole number is 64.







      javascript






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 4 '17 at 19:01









      user2260571user2260571

      235




      235
























          3 Answers
          3






          active

          oldest

          votes


















          4














          The function Math.pow(base, exponent) might be what you are looking for.



          You would do this:
          Math.pow(variable_for_A1, variable_for_A2) * 100






          share|improve this answer


























          • if I go with Math.power(99^45)*100, I end up having 6.361854860638708e+91 as results, while I am expecting to get 64. Any idea what am I missing?

            – user2260571
            Nov 4 '17 at 19:18











          • You should do Math.pow(0.99,45)*100, because 99% converted to decimal is 0.99, not 99.

            – iPhoenix
            Nov 4 '17 at 19:19



















          1














          Power function in JavaScript can be written (at least) in 2 ways.



          One is, as @iPhoenix described, another is,



          a**b





          console.log(1.93**7.2)
          console.log(2.0**6)
          console.log(2**6.2)
          console.log(7.9**43.2)








          share|improve this answer































            0














            The Correct Answer: in javascript math from excel percentage % value and power of function:



            Math.round(Math.pow((A1*1/100),A2)*100);



            Math.round(Math.pow((99*1/100),45)*100);



            The answer is: 64



            Without Math.pow Function



            Math.round(((A1*1/100)**A2)*100);



            Math.round(((99*1/100)**45)*100);



            The answer is: 64




            The Second way is to change the format cell data type from percentage % to number;







            share|improve this answer

























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f47114462%2fexcel-power-of-function-to-js%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              4














              The function Math.pow(base, exponent) might be what you are looking for.



              You would do this:
              Math.pow(variable_for_A1, variable_for_A2) * 100






              share|improve this answer


























              • if I go with Math.power(99^45)*100, I end up having 6.361854860638708e+91 as results, while I am expecting to get 64. Any idea what am I missing?

                – user2260571
                Nov 4 '17 at 19:18











              • You should do Math.pow(0.99,45)*100, because 99% converted to decimal is 0.99, not 99.

                – iPhoenix
                Nov 4 '17 at 19:19
















              4














              The function Math.pow(base, exponent) might be what you are looking for.



              You would do this:
              Math.pow(variable_for_A1, variable_for_A2) * 100






              share|improve this answer


























              • if I go with Math.power(99^45)*100, I end up having 6.361854860638708e+91 as results, while I am expecting to get 64. Any idea what am I missing?

                – user2260571
                Nov 4 '17 at 19:18











              • You should do Math.pow(0.99,45)*100, because 99% converted to decimal is 0.99, not 99.

                – iPhoenix
                Nov 4 '17 at 19:19














              4












              4








              4







              The function Math.pow(base, exponent) might be what you are looking for.



              You would do this:
              Math.pow(variable_for_A1, variable_for_A2) * 100






              share|improve this answer















              The function Math.pow(base, exponent) might be what you are looking for.



              You would do this:
              Math.pow(variable_for_A1, variable_for_A2) * 100







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Apr 24 '18 at 22:38

























              answered Nov 4 '17 at 19:04









              iPhoenixiPhoenix

              339412




              339412













              • if I go with Math.power(99^45)*100, I end up having 6.361854860638708e+91 as results, while I am expecting to get 64. Any idea what am I missing?

                – user2260571
                Nov 4 '17 at 19:18











              • You should do Math.pow(0.99,45)*100, because 99% converted to decimal is 0.99, not 99.

                – iPhoenix
                Nov 4 '17 at 19:19



















              • if I go with Math.power(99^45)*100, I end up having 6.361854860638708e+91 as results, while I am expecting to get 64. Any idea what am I missing?

                – user2260571
                Nov 4 '17 at 19:18











              • You should do Math.pow(0.99,45)*100, because 99% converted to decimal is 0.99, not 99.

                – iPhoenix
                Nov 4 '17 at 19:19

















              if I go with Math.power(99^45)*100, I end up having 6.361854860638708e+91 as results, while I am expecting to get 64. Any idea what am I missing?

              – user2260571
              Nov 4 '17 at 19:18





              if I go with Math.power(99^45)*100, I end up having 6.361854860638708e+91 as results, while I am expecting to get 64. Any idea what am I missing?

              – user2260571
              Nov 4 '17 at 19:18













              You should do Math.pow(0.99,45)*100, because 99% converted to decimal is 0.99, not 99.

              – iPhoenix
              Nov 4 '17 at 19:19





              You should do Math.pow(0.99,45)*100, because 99% converted to decimal is 0.99, not 99.

              – iPhoenix
              Nov 4 '17 at 19:19













              1














              Power function in JavaScript can be written (at least) in 2 ways.



              One is, as @iPhoenix described, another is,



              a**b





              console.log(1.93**7.2)
              console.log(2.0**6)
              console.log(2**6.2)
              console.log(7.9**43.2)








              share|improve this answer




























                1














                Power function in JavaScript can be written (at least) in 2 ways.



                One is, as @iPhoenix described, another is,



                a**b





                console.log(1.93**7.2)
                console.log(2.0**6)
                console.log(2**6.2)
                console.log(7.9**43.2)








                share|improve this answer


























                  1












                  1








                  1







                  Power function in JavaScript can be written (at least) in 2 ways.



                  One is, as @iPhoenix described, another is,



                  a**b





                  console.log(1.93**7.2)
                  console.log(2.0**6)
                  console.log(2**6.2)
                  console.log(7.9**43.2)








                  share|improve this answer













                  Power function in JavaScript can be written (at least) in 2 ways.



                  One is, as @iPhoenix described, another is,



                  a**b





                  console.log(1.93**7.2)
                  console.log(2.0**6)
                  console.log(2**6.2)
                  console.log(7.9**43.2)








                  console.log(1.93**7.2)
                  console.log(2.0**6)
                  console.log(2**6.2)
                  console.log(7.9**43.2)





                  console.log(1.93**7.2)
                  console.log(2.0**6)
                  console.log(2**6.2)
                  console.log(7.9**43.2)






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 4 '17 at 19:10









                  marmeladzemarmeladze

                  4,27731231




                  4,27731231























                      0














                      The Correct Answer: in javascript math from excel percentage % value and power of function:



                      Math.round(Math.pow((A1*1/100),A2)*100);



                      Math.round(Math.pow((99*1/100),45)*100);



                      The answer is: 64



                      Without Math.pow Function



                      Math.round(((A1*1/100)**A2)*100);



                      Math.round(((99*1/100)**45)*100);



                      The answer is: 64




                      The Second way is to change the format cell data type from percentage % to number;







                      share|improve this answer






























                        0














                        The Correct Answer: in javascript math from excel percentage % value and power of function:



                        Math.round(Math.pow((A1*1/100),A2)*100);



                        Math.round(Math.pow((99*1/100),45)*100);



                        The answer is: 64



                        Without Math.pow Function



                        Math.round(((A1*1/100)**A2)*100);



                        Math.round(((99*1/100)**45)*100);



                        The answer is: 64




                        The Second way is to change the format cell data type from percentage % to number;







                        share|improve this answer




























                          0












                          0








                          0







                          The Correct Answer: in javascript math from excel percentage % value and power of function:



                          Math.round(Math.pow((A1*1/100),A2)*100);



                          Math.round(Math.pow((99*1/100),45)*100);



                          The answer is: 64



                          Without Math.pow Function



                          Math.round(((A1*1/100)**A2)*100);



                          Math.round(((99*1/100)**45)*100);



                          The answer is: 64




                          The Second way is to change the format cell data type from percentage % to number;







                          share|improve this answer















                          The Correct Answer: in javascript math from excel percentage % value and power of function:



                          Math.round(Math.pow((A1*1/100),A2)*100);



                          Math.round(Math.pow((99*1/100),45)*100);



                          The answer is: 64



                          Without Math.pow Function



                          Math.round(((A1*1/100)**A2)*100);



                          Math.round(((99*1/100)**45)*100);



                          The answer is: 64




                          The Second way is to change the format cell data type from percentage % to number;








                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Dec 31 '18 at 5:41

























                          answered Nov 2 '18 at 12:04









                          Muhammad Imran SiddiqueMuhammad Imran Siddique

                          112




                          112






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f47114462%2fexcel-power-of-function-to-js%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Monofisismo

                              Angular Downloading a file using contenturl with Basic Authentication

                              Olmecas