首页  >  问答  >  正文

如何在javaScript中将字符串转换为19位数字而不自动舍入?

我们有字符串输入数字 输入=“6145390195186705543” 如果我们想转换为数字;java脚本自动舍入此输入;

(6145390195186705543)

(6145390195186705000)

P粉652495194P粉652495194183 天前381

全部回复(1)我来回复

  • P粉025632437

    P粉0256324372024-03-31 12:23:41

    这应该适合您想要实现的目标

    const myFunction = (num) => {
    
    const length = num.length;
    
    const result = `(${num.slice(0,16).padEnd(length, "0")})`;
    return result;
    };
    
    const input="6145390195186705543";
    const output = myFunction(input); 
    console.log(output)

    回复
    0
  • 取消回复