누군가 다음과 같은 설명 할 수 있습니다 System.Numerics.BigInteger
?Math.Log10 vs. BigInteger.Log10 동작을 설명 할 수 있습니까?
Console.WriteLine(Math.Log10(100)); // prints 2
Console.WriteLine(Math.Log10(1000)); // prints 3 (as expected)
Console.WriteLine((int)Math.Log10(100)); // prints 2
Console.WriteLine((int)Math.Log10(1000)); // prints 3 (as axpected)
var bi100 = new BigInteger(100);
var bi1000 = new BigInteger(1000);
Console.WriteLine(BigInteger.Log10(bi100)); // prints 2
Console.WriteLine(BigInteger.Log10(bi1000)); // prints 3 (as axpected)
Console.WriteLine((int)BigInteger.Log10(bi100)); // prints 2
Console.WriteLine((int)BigInteger.Log10(bi1000)); // prints 2 ???????
Console.WriteLine(Math.Floor(BigInteger.Log10(bi100))); // prints 2
Console.WriteLine(Math.Floor(BigInteger.Log10(bi1000))); // prints 2 ???????
Console.WriteLine(Math.Round(BigInteger.Log10(bi100))); // prints 2
Console.WriteLine(Math.Round(BigInteger.Log10(bi1000))); // prints 3 (as expected)
편집 : 나는 그것이 rouding 문제가 있다고 알고 있습니다. 내가 알고 싶습니다 왜 Math.Log10과 BigInteger.Log10의 동작이 다릅니다.
마지막 줄에 코드 주석이 올바르지 않습니다. 3 (적어도 나를 사용하는 경우) –
@Mitch : Corrected. – schnaader