如果您在Firefox和Chrome中运行此代码,它将输出不同的转换字符串.
(0.1234).toString(36)
在Firefox中,它将返回值“0.4fxcm49g2j8”
在Chrome或Node 4中(可能是V8差异),我得到的值为“0.4fxcm49g2j91m31w5nq6ldte29”.
在IE和Edge中它是“0.4fxcm49g2j91”(感谢@JaromandaX)
谁知道为什么?只是好奇.
最佳答案
似乎Firefox会在max_chars之后剪切字符串(对于每个表示基础都不同),而Chrome则不然.
原文链接:https://www.f2er.com/js/429106.html我没有在MDN中找到任何有效的引用,但如果你检查(例如)radix = 35的相同内容:
Firefox: "0.4b5r4d4d4d4"
Chrome: "0.4b5r4d4d4d4ar1synaijrkxa67ojifsn1fyljg8bny4ix53gyasaqys92cxcprnbsg27hs9ht7wb3o3i0ibfu9wvlyykt2evoykvyrva0n0wotvvtjxxnc98bptr68t77wl74xpwsf0iui8gtkhw45c9bhxkw8q6ltnpjti9110jqhdfxn3572gy3gsg74j7b55ids0vyfldmp2m4q32a7m1bf392ag1cppfwt1hvs57ne98v1ep5pa8un6bymql44dv1b6digg657rl1t82myanxb2q3nwf20vk1rl3rlylnbxansyhyuhie6pl1kmsqdhqhkmoqbanpj0d2vyiqxao70qrgarpyw7hdkdlly2048jx1f9ojl8417lr7j7f33d74r2bycapvhuq5vxr869r433q5rip9kpe7wft319p211af7x3v28f3ibto7s3c7rpg53kfbhtt23rta17fqw3653psp1febq2veigemernc4q85hjwx86awmb0npiqnm3f4994c9pu02bbn0nde9fnaqnmx68yp0q1itvc4jisckdtf08d26k4oha3lsh6g26o9pfoppwyrtbqgdpav2i2k0dhucraowuuoysx9h4ii3ht4qx9snj5w1k7nxnpspstd56dw8efbah6ly1km21g7nntn4sxup3fan1j576jbh02w1ixr5xivir0npqfdykndh5tcr32n6jt5lpe7a1u7efqkpdjgkwtmi3k2bcs4nuvkp6o5ds9l9biuw9td0ofhtgyffgyu5w4twliug2mkmpy9lk8m1pk211gfiwvutp5t0qfclfo0in7b3nml3s578aybv9yovwwvwn428bvuitux4lfgxenv93jp2dovf3fr73nhxrqik7u086crrtq7gm1xqw2i5ikkr8cxjyufvehpyqebse3ioex82yqn835p8g2xriidikp96swm2vfjwwdt54xurj2ufhdy0b805gixv9vrwcuf2rd56dtkgonpipcswbg1cjfxddbwlxwmew0xymmfv972enwa0wjuakcd2fswl4e4794bs7gqvcgaksxh21tjs74r9b9rwun4x8osk"
您可以在所有浏览器中检查:
for (var i = 11; i <=36; i++) {
console.log(i,(0.1234).toString(i).length,(0.1234).toString(i));
}
在chrome中,我得到的最大长度是1101,而在firefox中它是19.
It looks like some kind of rounding when converting the numbers between bases,however I’m not sure sure which/when/what round firefox applies here.