在http://learnxinyminutes.com/docs/julia/上阅读Julia时,我发现了这个:
# You can define functions that take a variable number of
# positional arguments
function varargs(args...)
return args
# use the keyword return to return anywhere in the function
end
# => varargs (generic function with 1 method)
varargs(1,2,3) # => (1,2,3)
# The ... is called a splat.
# We just used it in a function definition.
# It can also be used in a fuction call,
# where it will splat an Array or Tuple's …Run Code Online (Sandbox Code Playgroud) 我很难理解如何BigInt正确使用.在我看来,应该使用BigInt何时Int64或Int128不够,并且显然BigInt使用任意精度算术(我不知道).
假设我想计算一些大数的阶乘,例如30.我不知道需要存储多少位factorial(30)但两者都要
test = Int128
test = factorial(30)
Run Code Online (Sandbox Code Playgroud)
和
test = BigInt
test = factorial(30)
Run Code Online (Sandbox Code Playgroud)
产生-8764578968847253504明显不正确的产品.
根据Julia lang文档,似乎通常的数学运算符是为这种类型定义的(BigInt),结果被提升为a BigInt.因此,我没有看到我做错了什么,我显然误解了一些事情.希望你们中的一些人可能对我有一个解释:)
PS:如果有话要说,我正在运行64位版本的Windows 7