From 6a1d6212ae2de8f31eb43a68a214eeea8d6b5e54 Mon Sep 17 00:00:00 2001 From: phil Date: Thu, 22 May 1997 15:21:47 +0000 Subject: [PATCH] Fix a bug in bc_sqrt for numbers between 0 and 1. --- gnu/usr.bin/bc/number.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gnu/usr.bin/bc/number.c b/gnu/usr.bin/bc/number.c index e1ada04b4168..d334ed2fbb0a 100644 --- a/gnu/usr.bin/bc/number.c +++ b/gnu/usr.bin/bc/number.c @@ -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);