A
A
Andrey2021-01-11 13:55:44
JavaScript
Andrey, 2021-01-11 13:55:44

How to raise decimal to floating point power?

Given the number 1.000001, when raised to a power of 2**19, we get result: 1.6892552271606103 There is a custom function that does the same thing, but a different result comes out.
1.000001**2**19



function costumePow(num, pow) {
    for(let i = 0; i < pow; i++)
    {
        num *= num;
    }
    return num;
}


result: 1.689255227180379 The

question is how to rewrite the function so that the answers match.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
Wataru, 2021-01-11
@wataru

You messed something up.
1.000001**2**19 also returns 1.689255227180379. Just checked in console.

> costumePow(1.000001, 19)
1.689255227180379
> 1.000001**2**19
1.689255227180379

K
krka92, 2021-01-11
@krka92

Find one difference is called
5ffc6a113d629013687875.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question