source

PowerShell 및 C#의 BigInt 불일치

factcode 2023. 10. 31. 22:54
반응형

PowerShell 및 C#의 BigInt 불일치

마이크로소프트 문서에 따르면[BigInt]데이터 유형은 정의된 최대값이 없는 것 같고 이론적으로는 무한히 큰 숫자를 유지할 수 있습니다. 하지만 28자리 이후에는 이상한 일들이 발생하기 시작합니다.

PS C:\Users\Neko> [BigInt]9999999999999999999999999999
9999999999999999999999999999
PS C:\Users\Neko> [BigInt]99999999999999999999999999999
99999999999999991433150857216

보시다시피 첫번째 명령에서1BigInt의도한 대로 작동하지만, 한 자리가 더 늘어나면 번역되는 곳에서 약간의 탈락이 발생하는 것처럼 보입니다.99999999999999999999999999999.99999999999999991433150857216그러나 프롬프트가 표시되면 오류가 발생하지 않으며 310번째 숫자까지 계속 숫자를 추가할 수 있습니다.

PS C:\Users\Neko> [BigInt]99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
100000000000000001097906362944045541740492309677311846336810682903157585404911491537163328978494688899061249669721172515611590283743140088328307009198146046031271664502933027185697489699588559043338384466165001178426897626212945177628091195786707458122783970171784415105291802893207873272974885715430223118336
PS C:\Users\Neko\> [BigInt]999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999

실수를 던져줄 것입니다

At line:1 char:318
+ ... 999999999999999999999999999999999999999999999999999999999999999999999
+                                                                          ~
The numeric constant 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 is not valid.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : BadNumericConstant

내가 생각하기에 그것은 콘솔 문제입니다.BigInt오류가 언급되지 않았기 때문에 문제가 발생합니다.[BigInt]데이터 유형은 다른 데이터 유형에 비해 너무 큰 숫자와는 다릅니다.

PS C:\Users\Neko> [UInt64]18446744073709551615
18446744073709551615
PS C:\Users\Neko> [UInt64]18446744073709551616
Cannot convert value "18446744073709551616" to type "System.UInt64". Error: "Value was either too large or too small
for a UInt64."
At line:1 char:1
+ [UInt64]18446744073709551616
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastIConvertible

C#에 관해서는,System.Numerics.BigInt20번째 자리에서 오류를 던지기 시작할 겁니다99999999999999999999하드 코딩된 경우:

namespace Test
{
    class Test
    {
        static void Main()
        {
            System.Numerics.BigInteger TestInput;
            System.Numerics.BigInteger Test = 99999999999999999999;
            System.Console.WriteLine(Test);
        }
    }
}

Visual Studio에서 빌드하려고 하면 오류가 발생합니다.

Integral constant is too large

하지만 더 많은 숫자를 입력할 수 있습니다.ReadLine착오 없이

namespace Test
{
    class Test
    {
        static void Main()
        {
            System.Numerics.BigInteger TestInput;
            TestInput = System.Numerics.BigInteger.Parse(System.Console.ReadLine());
            System.Console.WriteLine(TestInput);
        }
    }
}

정말 무한한 것 같습니다.인풋

99999999999...

(총 24720자) 정상2 작동

그렇다면 이 이상한 활동의 원인은 무엇일까요?[BigInt]?


1 28자리의 숫자를 기준으로 했을때([Char[]]"$([BigInt]9999999999999999999999999999)").count

2 숫자를 세는 데 너무 게을러서 PowerShell에 숫자를 파싱하려고 하면 오류가 발생합니다.이것에 의하면 24720자입니다.

TLDR: 사용[BigInt]::Parse아니면'literal'Powershell Core 7.0 이전의 구문; 그렇지 않으면 사용합니다.n접미사

- -double문학의

고정되지 않은 리터럴의 경우 Powershell은 값이 적합한 첫 번째 유형을 사용합니다.적분 리터럴의 순서는int,long,decimal그리고 나서.double. Powershell 5.1에 대한 설명서(bolding mine; 이 단락은 Powershell Core의 경우 동일):

유형 접미사가 없는 정수 리터럴의 경우:

  • 값을 유형별로 나타낼 수 있는지 여부[int], 그것이 그 유형입니다.
  • 그렇지 않으면 유형별로 값을 나타낼 수 있는지 여부[long], 그것이 그 유형입니다.
  • 그렇지 않으면 유형별로 값을 나타낼 수 있는지 여부[decimal], 그것이 그 유형입니다.
  • 그렇지 않으면 유형별로 표시됩니다.

당신의 경우 그 값은 다음 값을 초과합니다.decimal.MaxValue그래서 당신의 리터럴은 기본적으로 a.double문자 그대로의그거double값은 정확하게 표현할 수 없으며 가장 가까운 표현 가능한 두 배에 "converted"입니다.

$h = [double]99999999999999999999999999999
"{0:G29}" -f $h

산출물

99999999999999991000000000000

분명히 그건 정확한 숫자가 아니라 문자열 형태의 표현일 뿐입니다.하지만 무슨 일이 일어나고 있는지 알 수 있습니다.이제 우리는 이것을 정확하지 않게 받아들입니다. double가치와 우리는 그것을 하기 위해 던집니다.BigInt. 원래의 정밀도 손실은 변환 연산자에 의해 이전되고 복합화됩니다.이것이 실제로 파워셸에서 일어나고 있는 일입니다. (출연진이 주목할 것은 다음과 같습니다.BigInt):

$h = [BigInt][double]99999999999999999999999999999
"{0:G}" -f $h

산출물

99999999999999991433150857216

이것은 사실 가장 가까운 대표적인 것입니다.doublevalue. 만약 당신이 정확한 값을 인쇄할 수 있다면.double첫번째 예시에서, 이것은 인쇄될 것입니다.추가 숫자를 추가하면 숫자 리터럴의 가장 큰 값을 초과하므로 받은 다른 예외도 있습니다.

C# 불일치

파워셸과 달리 C#은 기본적으로 적분 리터럴을 사용하므로 훨씬 적은 숫자에 대해 예외를 적용합니다.추가하기DC#의 접미사는 더 큰 범위를 제공합니다.다음은 잘 작동하며 다음과 같이 될 것입니다.double.

var h = 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999D;

한 자리를 더 추가하면 다음 오류가 발생합니다.

오류 CS0594: 부동 소수점 상수가 'double' 유형의 범위를 벗어났습니다.

참고로 파워셸에서는D접미사는 다음에 사용됩니다.decimal문학적인 것과 그렇지 않은 double. 에 대한 명시적 접미사가 없습니다.double--기본값으로 가정합니다.

해결책

원래 문제로 돌아가서, Powershell 버전에 따라 솔루션이 달라질 수 있습니다.

[BigInt]::Parse

Windows Powershell 또는 Powershell Core <= v6.2를 사용하는 경우 다음과 같은 방법을 사용할 수 있습니다.BigInteger.Parse:

[bigint]::Parse("99999999999999999999999999999") 

출력:

99999999999999999999999999999

Large Value Literals

주석에서 지적한 바와 같이, 리터럴을 따옴표로 묶는 것도 효과적인 방법입니다.

[bigint]'99999999999999999999999999999' 

산출물

99999999999999999999999999999

겉보기에 상관없이, 이것은 의 약자가 아닙니다.[bigint]::new([string])(아래 참조).이것은 대신에 리터럴이 a로 취급되지 않도록 보장하는 방법입니다.double그러나 많은 숫자를 가진 통합 리터럴, 소위 "큰 값 리터럴"로서.문서의 이을 참조하십시오.

N사(v7.0+)

파워셸 코어 6.2는 서명되지 않은 것과 같은 적분형을 위한 많은 새로운 문자 접미사들을 소개했습니다.short,그리고.byte하지만 한 개를 소개하지 않았습니다.bigint. 그것은 파워셸 코어 7.0을 통해 출시되었습니다.n접미사이제 할 수 있음을 의미합니다.이는 이제 다음을 수행할 수 있음을 의미합니다.

99999999999999999999999999999n 

출력:

99999999999999999999999999999

Powershell Core에서 사용할 수 있는 접미사에 대한 자세한 내용은 설명서를 참조하십시오.

[BigInt]::new

만약 당신이 시도해본다면.[bigint]::new('literal')Powershell은 을 리터럴로 사용하려는 것을 인식합니다.이를 위한 시공자가 없습니다.BigIntA를 받아들이는.string(우리는 사용합니다.Parse그것을 위해) 또한 다른 건설자를 받아들이는 건설자가 없습니다.BigInt. 그러나 다음을 수행하는 시공자가 있습니다.double. 우리의 대용량 리터럴은 다음과 같이 시작할 것입니다.BigInt, 그러면 파워셸은 그것을 암시적으로 a로 전환할 것입니다.double(losing 정밀도) 다음에 전달[bigint]::new([double])다시 한 번 잘못된 결과를 제공하는 것이 가장 좋은 경기입니다.

[bigint]::new('99999999999999999999999999999') 

출력:

99999999999999991433150857216

불행하게도 C#은 BigInteger를 위한 리터럴을 가지고 있지 않습니다.BigInteger를 인스턴스화하는 두 가지 방법이 있습니다.

  1. int, long(캐스트 또는 생성자 사용)과 같은 프리미티브 유형에서 변환
  2. BigInteger.Parse를 사용하여 문자열에서 구문 분석

BigInteger test = BigInteger.Parse("32439845934875938475398457938457389475983475893475389457839475");
Console.WriteLine(test.ToString());
// output: 32439845934875938475398457938457389475983475893475389457839475

PowerShell이 숫자 리터럴을 구문 분석하는 방법 보기

기존의 유용한 답변 - 특히 핑크 플로이드 x33의 답변 - 을 간결한 요약으로 보완합니다.

기본적으로 v7.0 이상의 모든 PowerShell 버전은 보다숫자 리터럴데이터 유형으로 사용되므로 항상 정확도떨어집니다.

  • v6.x(Windows PowerShell 포함)까지 이를 방지할 수 있는 유일한 방법은 문자열 표시되는 숫자와 함께 사용하는 것입니다.
[bigint]::Parse('99999999999999999999999999999')

# A *cast* works too, as also shown in pinkfloydx33's answer:
[bigint] '99999999999999999999999999999'
  • v7+에서는 접미사를 사용하여 숫자 리터럴을 a로 지정할 수 있습니다.[bigint]:
99999999999999999999999999999n  # v7+; parses as a [bigint], due to suffix 'n'

참고: PowerShell이 일반적으로 적절한 숫자 유형을 자동으로 선택한다는 점을 고려할 때, 다음과 같이 가정해야 합니다. n이 경우, 즉 그것은 고정되지 않은 것을 파싱해야 합니다.99999999999999999999999999999[bigint], 로는 아닌[double]- 이 GitHub 제안서를 보세요.


추가 읽기:

  • 어떤 PowerShell 버전에 도입되었는지를 비롯하여 모든 숫자 유형 접미사를 보여주는 _Numeric_Literals에 대해 참조하십시오.

  • 답변은 PowerShell에서 리터럴 수를 어떻게 해석하는지 요약한 것입니다.

    • 간단히 말해서, 정수 리터럴의 경우,[int]선택된 유형 중 가장 작은 유형입니다.[long]아니면[decimal]더 큰 값을 수용하기 위해 필요에 따라 선택됩니다.[double]그 이상의 가치를 위해 사용되는[decimal]::MaxValue.

메타데이터 관점에서 정보를 좀 더 제공하면

PowerShell과 C#은 둘 다 동일한 모듈을 사용합니다..NET CoreBigInt데이터 유형 및 데이터 유형을 볼 수 있습니다.BigInteger짜맞추다

C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\System.Runtime.Numerics.dll

여기에는 다음에 대한 컨스트럭터가 포함됩니다.

public BigInteger(byte[] value);
public BigInteger(decimal value);
public BigInteger(double value);
public BigInteger(int value);
public BigInteger(long value);
public BigInteger(float value);
public BigInteger(uint value);
public BigInteger(ulong value);
public BigInteger(ReadOnlySpan<byte> value, bool isUnsigned = false, bool isBigEndian = false);

그 말은 베이스가

System.Numerics.BigInteger test = 12345;

생성자에게 전달된 값을 사용할 수 있는 가장 높은 값, 즉 최대값 중 하나로 변환하려고 합니다.double, 그러나 C#은 접미사가 필요 없는 최대값이 다음과 같이 되도록 접미사와 함께 지정되지 않는숫자를 더블로 변환하려고 시도하지 않습니다.ULong최대 값을 가지는18446744073709551615면)에 의거)ULong.MaxValue) 이보다 더 적습니다.99999999999999999999, 적분 상수 오차를 발생시켰지만 다음보다 큰 수9999999999999999999, 한 글자를 뺀이것이 단지 하는 이유입니다.

System.Numerics.BigInteger test = 99999999999999999999;

오류가 발생합니다.하지만, 그Parse()메소드 인BigInteger는 생성자에서 정수 타입 이외의 값을 가져올 수 있으며 문자열을 사용합니다.

public static BigInteger Parse(ReadOnlySpan<char> value, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null);
public static BigInteger Parse(string value);
public static BigInteger Parse(string value, NumberStyles style);
public static BigInteger Parse(string value, NumberStyles style, IFormatProvider provider);
public static BigInteger Parse(string value, IFormatProvider provider);

보시다시피.Parse()의 방법System.Numerics.BigInteger는 정수가 아닌 단어이므로 제한이 없는 문자열 인수를 사용합니다.이것이 그 이유입니다.Parse()method는 당신에게 무한한 가치공간을 제공할 입니다.

PowerShell의 경우, 다른 답변에서와 마찬가지로, 최대값을 초과하는 것은 부정확성많은 데이터 유형으로 변환을 시도합니다.[double]data type의 최대값은 309자리이므로 오류는 309자리 뒤에만 나타납니다.

[double]::MaxValue
1.79769313486232E+308

이것을 과학적 표기법이 아닌 정상치로 변환하기 위해 우리는 소수점을 308번 이상 이동시킬 것입니다.

179769313486232000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

가능한 최고의 두 배가 될 겁니다PowerShell의 '[double] data type은 다음과 같이 매우 부정확한 매우 이상한 속성을 가지고 있습니다.

[BigInt][double]9999999999999999999999
10000000000000000000000
[BigInt][double]9999999999999999999999999
10000000000000000905969664
[double]9999999999999999999
1E+19

에서 PowerShell 를 수 .BigInt또한 C#과 같은 구조에서, 방법과 생성자는 같고 그리고Parse()또한 C#에서와 마찬가지로 PowerShell에서도 동일한 방식으로 작동할 것입니다.PowerShell 7에 변경 사항이 있어 다음과 같은 작업을 수행할 수 있었습니다.N자동으로 바로 변환될 접미사BigInt.

BigInt또한 과학적 표기법을 사용하지 않으므로 사용할 수 있는 정확한 값을 얻기 위해 다른 데이터 유형을 사용하면 항상 정확한 값을 얻을 수 있습니다.

[BigInt]([double]::MaxValue)

당신을 얻을 것입니다.

179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368

가능한 최고의 두 배가 될 겁니다


원하는 명령어

PowerShell 6.x 이하

[BigInt]::Parse("99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999")

PowerShell 7.0 이상

99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999N

C#

System.Numerics.Biginteger test = System.Numerics.BigInteger.Parse("999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999")

언급URL : https://stackoverflow.com/questions/62974138/bigint-inconsistencies-in-powershell-and-c-sharp

반응형