我注意到在将字符串转换为base36时,Python和JavaScript之间存在一些不一致之处。将字符串转换为语言之间的base36不一致性。
Python的方法:
>>> print int('abcdefghijr', 36)
结果:37713647386641447
JavaScript方法:
<script>
document.write(parseInt("abcdefghijr", 36));
</script>
结果:37713647386641450
什么导致两种语言之间的不同结果?无论语言如何产生相同结果,最好的方法是什么?
谢谢。
请参阅http://stackoverflow.com/questions/5812096/javascript-large-integer-round-because-precision-why; javascript没有像Python那样的大整数的任意精度。 (只需在javascript控制台中键入'37713647386641447'会给你相同的取整值) – geoffspear