0
그래서 BigInteger를의 제곱근을 찾기 위해 뉴턴 - 랩슨 방법을 사용하려고 시도하고있다. - 그것은 소수 장소를 필요로 즉C#에서의 BigInteger의 제곱근을 찾기 위해 뉴턴 - 랩슨 방법을 사용하는 방법
private void sqrRt(BigInteger candidate)
{
BigInteger epsilon = new BigInteger(0.0001);
BigInteger guess = candidate/2;
while (BigInteger.Abs(guess * guess - candidate) >= epsilon)
{
// guess = guess - (((guess**2) - y)/(2*guess))
guess = BigInteger.Subtract(guess, BigInteger.Divide(BigInteger.Subtract(BigInteger.Multiply(guess, guess), candidate), BigInteger.Multiply(2, guess)));
MessageBox.Show(Convert.ToString(guess));
}
}
문제는 BigInteger를이 while 루프에서 엡실론의 정확성의 정도 내에 충분히 정확하지 것 같다 :
여기 내 코드입니다. 내 질문은 어떻게/어떻게/어디에 두 번 루프를 결국 false를 반환하게 변환합니까?
ummm 'BigInteger'는 부동 소수점 연산이 아닌 정수를위한 것입니다. –
가능한 중복 [BigInteger (System.Numerics.BigInteger)의 제곱근 계산] (http://stackoverflow.com/questions/3432412/calculate-square-root-of-a-biginteger-system-numerics-biginteger) – AlexH
그렇다면 매우 큰 숫자로 어떻게 부동 소수점 연산을 수행 할 수 있습니까? 당신은'사용할 수 있습니다 더 정확성을 – Gerald