gpt4 book ai didi

用于保存大量数字的 PowerShell 变量类型

转载 作者:行者123 更新时间:2023-12-01 12:05:50 25 4
gpt4 key购买 nike

我需要在 PowerShell FOREACH 循环中处理大量数字。我收到以下异常:

Cannot convert value "60000000000" to type "System.Int32"

[long]$LargeNumber = 60000000000
foreach ($i in 1..$LargeNumber) {
$i
}

我做错了什么?

最佳答案

似乎 powershell 的范围运算符 (..) 存在限制,将输入参数限制为 Int32。我找不到官方文档,但是 according to this page :

2 Restrictions and a Caveat There are only two basic restrictions on range use. The first restriction is that the numbers in the range must be between -2,147,483,648 and 2,147,483,647, inclusive; this limit is because PowerShell's range operator changes the values into 32-bit .NET integers, which can only take on these values. The second limit is that an individual range can contain no more than 50,001 items.

关于用于保存大量数字的 PowerShell 变量类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57062678/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com