Javascript - 如何平方一个数字? [英] Javascript - How to squared a number?
问题描述
使用javascript函数
Using the javascript function
function squareIt(number) {
return number * number;
}
当给定数字 4294967296 时,函数返回 18446744073709552000 返回
When given the number 4294967296 the function returns 18446744073709552000 is returned
大家都知道真正的答案是18446744073709551616 :-)
Everyone knows the real answer is 18446744073709551616 :-)
我想这是为了在我的 32 位机器上进行舍入.但是,这个脚本会在 64 位机器上给出正确答案吗?有人试过吗?
I guess this is to to with rounding on my 32-bit machine. However, would this script give the right answer on a 64 bit machine? Has anyone tried this?
推荐答案
ChrisV- 看这篇文章.此外,通过在浏览器 URL 文本框中直接输入以下 JavaScript,人们可以更轻松地评估您的问题:
ChrisV- see this post. Also it easier for people to evaluate your question by typing the following JavaScript directly into the browser URL textbox:
javascript:4294967296*4294967296
这篇关于Javascript - 如何平方一个数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!