Excel “power of” function to JS
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
add a comment |
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
add a comment |
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
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
javascript
asked Nov 4 '17 at 19:01
user2260571user2260571
235
235
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
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
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
add a comment |
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)
add a comment |
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;
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
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
add a comment |
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
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
add a comment |
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
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
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
add a comment |
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
add a comment |
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)
add a comment |
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)
add a comment |
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)
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)
answered Nov 4 '17 at 19:10
marmeladzemarmeladze
4,27731231
4,27731231
add a comment |
add a comment |
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;
add a comment |
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;
add a comment |
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;
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;
edited Dec 31 '18 at 5:41
answered Nov 2 '18 at 12:04
Muhammad Imran SiddiqueMuhammad Imran Siddique
112
112
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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