Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/410.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript toExponential()中的差异_Javascript_Google Chrome_Firefox_Browser_Opera - Fatal编程技术网

Javascript toExponential()中的差异

Javascript toExponential()中的差异,javascript,google-chrome,firefox,browser,opera,Javascript,Google Chrome,Firefox,Browser,Opera,这是Firefox中的一个bug吗?其他浏览器也一样吗?有没有关于这方面的概述?这种差异有什么好的原因吗 +---- 4 vs. 5 | Firefox: 1.234e+4 (12345.0).toExponential(3); Chrome : 1.235e+4 (12345.0).toExponential(3); Opera : 1.235e+4 (12345.0).t

这是Firefox中的一个bug吗?其他浏览器也一样吗?有没有关于这方面的概述?这种差异有什么好的原因吗

             +---- 4 vs. 5
             |    
Firefox: 1.234e+4           (12345.0).toExponential(3);
Chrome : 1.235e+4           (12345.0).toExponential(3);
Opera  : 1.235e+4           (12345.0).toExponential(3);
以下是我对标准的解释:

:

x=12345.0//设x为该数值 ƒ=3//让ƒ成为整数(分数位数) s=”“//设s为空字符串。 如果x!=0定义的分形数字(&D) 10×铬/歌剧 如果结束 m=1235//设m是由 //n的十进制表示法。 a=1//设a为m的第一个字符 b=235//设b为m的剩余字符 m=a+“+b=1.235//设m是a+“+b”的串联 c=+//让c=“+” d=4//设d为字符串,由 //e的十进制数字。 m=m+“e”+c+d=1.235e+4 返回s+m 我走了吗

Linux

  • Mozilla Firefox 24.0
  • 歌剧12.16
  • 铬31.0.1650.48

你真的应该把问题的第二部分作为答案发布出来。你说得对-这是V8中的一个错误。@gsnedders:是的,也许吧。我会及时看到。。。 x = 12345.0 // Let x be this Number value ƒ = 3 // Let ƒ be ToInteger(fractionalDigits) s = "" // Let s be the empty String. IF x != 0 && defined fractianalDigits THEN 10׃ <= n < 10(ƒ + 1) // Value of n n × 10(e - ƒ) - x // Where closest to 0 // If there are two such sets of e and n, // pick the e and n for which n × 10e–ƒ is larger. 300 <= n < 10.000 1234 × 10(4 - 3) - 12345 = -5 => Firefox 1235 × 10(4 - 3) - 12345 = 5 => Chrome / Opera END IF m = 1235 // Let m be the String consisting of the digits of the // decimal representation of n. a = 1 // Let a be the first character of m b = 235 // Let b be the remaining characters of m m = a + "." + b = 1.235 // Let m be the concatenation of a + "." + b c = + // Let c = "+" d = 4 // Let d be the String consisting of // decimal digits of e. m = m + "e" + c + d = 1.235e+4 return s + m