开发者

how to convert number to string (without exponent)

开发者 https://www.devze.com 2023-01-17 11:42 出处:网络
sorry, but i\'m not that maths guy, so i do not know how it is really called: number 12345678901234567890123 could be also stated as 1.2345678901234567890123 * 10^22 (if i\'m right and did not miss a

sorry, but i'm not that maths guy, so i do not know how it is really called:

number 12345678901234567890123 could be also stated as 1.2345678901234567890123 * 10^22 (if i'm right and did not miss any decimal...)

consider this javascript:

var number = 12345678901234567890123;
var stringValue = number.toString();

if i do so, it renders the alternative translation (mentioned above). instead i want to render simple, plain, ... 12345678901234567890123

how can this be done?

开发者_运维知识库

EDIT:

just to be clear: the number i want to render, does not contain any decimal places. it's just a simple 12345678901234567890123 ... not 12345678901234567890123.123 or anything likewise. and, as i'm with javascript, typeof is number


if you still want to deal with numbers on the order of 10^22 without rounding, then you should use a BigInt class, which implements arbitrary sized numbers. There are several BigInt javascript implementations you can find on the net.

0

精彩评论

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

关注公众号