Fix a bug in bc_sqrt for numbers between 0 and 1.

This commit is contained in:
phil 1997-05-22 15:21:47 +00:00
parent 76c3314d9b
commit 6a1d6212ae
1 changed files with 6 additions and 3 deletions

View File

@ -1209,8 +1209,11 @@ bc_sqrt (num, scale)
/* Calculate the initial guess. */
if (cmp_res < 0)
/* The number is between 0 and 1. Guess should start at 1. */
guess = copy_num (_one_);
{
/* The number is between 0 and 1. Guess should start at 1. */
guess = copy_num (_one_);
cscale = (*num)->n_scale;
}
else
{
/* The number is greater than 1. Guess should start at 10^(exp/2). */
@ -1221,11 +1224,11 @@ bc_sqrt (num, scale)
guess1->n_scale = 0;
bc_raise (guess, guess1, &guess, 0);
free_num (&guess1);
cscale = 3;
}
/* Find the square root using Newton's algorithm. */
done = FALSE;
cscale = 3;
while (!done)
{
free_num (&guess1);