开发者

Displaying a large value (Trillion) in a table in decimal form e.g 5.8 trillion

开发者 https://www.devze.com 2023-03-21 15:58 出处:网络
I need to add a new column to my sharepoint dashboard(created using Jquery). The value is a number which is extremly large and causing my dashboard to become mis figured. I have values in the trillion

I need to add a new column to my sharepoint dashboard(created using Jquery). The value is a number which is extremly large and causing my dashboard to become mis figured. I have values in the trillions e.g (565000000000.001) .

I need 开发者_JAVA百科to dipaly this value in decimal e.g 5.65 trillion. Can someone please point me in the right direction :)

My table code below:

       TableRowHtml +="<TR><TD style='text-align: Left'>Curr</TD><TD 'style='font-size: 10px'>" + Curr[0].toFixed(2) + "</TD><TD 'style='font-size: 10px'>" + Curr[1].toFixed(2)+ "</TD><TD 'style='font-size: 10px'><img alt='' src=' IMAGE" + Curr1 + "'></TD><TD 'style='font-size: 10px'><img alt='' src=' IMAGE" + Curr7 + "'></TD><TD 'style='font-size: 10px'><img alt='' src='IMAGE" + Curr30 + "'></TD><TD 'style='font-size: 10px'> <div id='div3' style='float: right; width: 75px;  height: 30px; margin-bottom: -20px! important;'></div></TD></TR>";


Divide value by a trillion, then round down to 2 decimals.

And in case you can not round to a certain amount of decimals: Divide value by a trillion/100 (ie 10.0000.000.000), then round, then divide by 100.

In code:

(Curr[1] / 1000000000000).toFixed(2)

And alternative (gives you 5 instead of 5.00)

(Curr[1] / 10000000000).toFixed(0)/100


Try dividing your huge value by 1012:

TableRowHtml += "<TR><TD style='text-align: left'>Curr</TD>"
    + "<TD style='font-size: 10px'>"
    + (Curr[0] / 1E12).toFixed(2) + " trillions" + "</TD>...";

By the way, I'm never sure of the trillion designation in English, but shouldn't 565 000 000 000.001 be 0.565 trillion?

0

精彩评论

暂无评论...
验证码 换一张
取 消