[comp.sources.bugs] binary display problem in calctool.

pac@munsell.UUCP (Paul Czarnecki) (07/29/87)

I have found a serious bug in how Rich Burridge's calctool program.
The program does not display binary numbers correctly.

For example:

	1) enter the number 4143710208
	2) go into binary mode
	3) the display will have
111101101111110000000000000000

This is incorrect.  There should be 18, not 16 zeroes on the right
hand side.

% bc
obase=2
4143710208
11110110111111000000000000000000

It seems to work fine on small numbered binary arithmetic.

Has anyone found a fix for this?  (I am running calctool V1.2 ona Sun
3/17 running SunOS 3.2.)

					pZ
-- 
			       Paul Czarnecki -- My newsfeed's in Esperanto
	{{harvard,ll-xn}!adelie,{decvax,allegra,talcott}!encore}!munsell!pz

richb@sunk.UUCP (09/02/87)

A little while ago Paul Czarnecki found a bug in calctool
when binary numbers near the capacity of the calculator
were being displayed incorrectly.

I put out a fix which partly fixed this problem but caused
the accuracy feature to work incorrectly.

Paul kindly mailed me his correction, and after we decided
that the calculator shouldn't try to grovel (the word sorry
was removed from the display message), we have a solution
that appears to work correctly.

This is for version 1.2. Again, I can't give diffs because
the version I'm currently working on it two releases later.

This is in the routine make_number in calctool.c:

  if ((ndig = ddig + accuracy) > cmax)
    {
      if (ddig > cmax) {
        STRCPY(display,"Overflow") ;
        display_result(display) ;
        error = 1 ;
        return ;
      } else {
        STRCPY(display, "Reducing precision") ;
        display_result(display) ;
        sleep(1) ;
        bzero(display);
        accuracy = cmax - ddig ;
        if (accuracy < 0) accuracy = 0;
        ndig = ddig + accuracy;
      }
    }

If this is all getting too confusing, then you might wish to
just wait for v1.4, which I've just posted to comp.sources.misc.

Sorry for the confusion, and thanks again Paul.

    Rich.

Rich Burridge,            JANET richb%sunk.oz@uk.ac.ucl.cs
ACSnet  richb@sunk.oz     UUCP {seismo,hplabs,ukc}!munnari!sunk.oz!richb
PHONE: +61 3 811 9927     ARPAnet richb%sunk.oz@seismo.css.gov
MAIL: Sun Microsystems, 123 Camberwell Rd, Hawthorn, VICTORIA 3122, AUST
D
D
D