最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

multiply and divide values with power of ten in javascript - Stack Overflow

programmeradmin3浏览0评论

how can i divide value that has power of 10 in javascript?

For example:

-5x10^-3 * 3x10^-9

is there a way to do this like a

Math.powof(5,-3)

something like that?

how can i divide value that has power of 10 in javascript?

For example:

-5x10^-3 * 3x10^-9

is there a way to do this like a

Math.powof(5,-3)

something like that?

Share Improve this question asked Aug 31, 2011 at 4:50 philipphilip 1,3023 gold badges24 silver badges44 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 4

Why not use exponent notation?

-5e-3 * 3e-9

which is equivalent to:

-0.005 * 0.000000003;

Note that when dealing with small decimals, javascript arithmatic may not be exact, e.g.

(-5 * Math.pow(10, -3)) * (3 * Math.pow(10,-9)) // -1.5000000000000003e-11

but

-5 * Math.pow(10, -3) * 3 * Math.pow(10,-9)  // -1.5e-11

You can try this:

5 × Math.pow(10,-3)

Almost, Math.pow(x, y) where x is is to the power of y so include it in whatever equation you need

Look at Math.pow(base,exponent), which lets you take base to the power of exponent. From there you can do something like this:

function powOf10(num,exp) {
   return num * Math.pow(10,exp);
}

alert(powOf10(5,-3));

here is the examples but what ur main functionality i didn't understand but look this hope you get some

(Math.pow((-5*10),-3)) * (Math.pow(3*10),-9)

or

(-5 * Math.pow(10,-3)) * (3 * Math.pow(10),-9)
发布评论

评论列表(0)

  1. 暂无评论