Javascript-如何对数字求平方? [英] Javascript - How to squared a number?
本文介绍了Javascript-如何对数字求平方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用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屋!
查看全文