1010#include <coco.h>
1111#include "fp09.h"
1212
13- #if 1 /* Change to 0 to use single precision. */
13+ /* Define SINGLE to use single precision */
14+ #ifdef DOUBLE
1415typedef fp09_double Float ;
1516#define FLOAT_TYPE_ID fp09_double_type
1617#else
@@ -67,6 +68,7 @@ int main()
6768 }
6869
6970 // wait for input
71+ check_error ( & fpcb );
7072 locate (31 ,0 );
7173 x = waitkey (TRUE);
7274
@@ -133,7 +135,6 @@ int main()
133135 if ( blank == FALSE ) stack_input_buffer ();
134136 fp09_FADD ( & fpcb , stack [1 ], stack [0 ], stack [0 ] );
135137 move_stack_up ();
136- check_error ( & fpcb );
137138 }
138139 else if (x == 'S' ) // Subtraction
139140 {
@@ -144,7 +145,6 @@ int main()
144145 fp09_FSUB ( & fpcb , stack [1 ], stack [0 ], stack [0 ] );
145146
146147 move_stack_up ();
147- check_error ( & fpcb );
148148 }
149149 else if (x == 'M' ) // Multiply
150150 {
@@ -155,7 +155,6 @@ int main()
155155 fp09_FMUL ( & fpcb , stack [1 ], stack [0 ], stack [0 ] );
156156
157157 move_stack_up ();
158- check_error ( & fpcb );
159158 }
160159 else if (x == 'D' ) // Divide
161160 {
@@ -165,7 +164,6 @@ int main()
165164 if ( blank == FALSE ) stack_input_buffer ();
166165 fp09_FDIV ( & fpcb , stack [1 ], stack [0 ], stack [0 ] );
167166 move_stack_up ();
168- check_error ( & fpcb );
169167 }
170168 else if (x == 'O' )
171169 {
@@ -192,7 +190,6 @@ int main()
192190
193191 if ( blank == FALSE ) stack_input_buffer ();
194192 fp09_FSQRT ( & fpcb , stack [0 ], stack [0 ] );
195- check_error ( & fpcb );
196193 }
197194 else if (x == 8 ) // delete key;
198195 {
@@ -387,10 +384,6 @@ void stack_input_buffer()
387384 printf ( " " );
388385
389386 }
390- else
391- {
392- check_error ( & fpcb );
393- }
394387}
395388
396389void draw_stack ()
@@ -420,15 +413,24 @@ void move_stack_up()
420413
421414void check_error ( fp09_FPCB * cb )
422415{
423- locate (1 ,0 );
424- printf ( "ERROR: " );
425- if ( cb -> status & fp09_status_undefined ) printf ( "UNDEFINED " );
426- if ( cb -> status & fp09_status_integer_overflow ) printf ( "INT OVERFLOW " );
427- if ( cb -> status & fp09_status_unordered ) printf ( "UNORDERED " );
428- if ( cb -> status & fp09_status_division_zero ) printf ( "DIV BY 0 " );
429- if ( cb -> status & fp09_status_underflow ) printf ( "UNDERFLOW " );
430- if ( cb -> status & fp09_status_overflow ) printf ( "OVERFLOW " );
431- if ( cb -> status & fp09_status_invalid_operation ) printf ( "INVALID " );
416+ locate (0 ,1 );
417+ printf ( "ERROR: " );
418+ if ( cb -> status == 0 )
419+ {
420+ printf ( "NONE\n" );
421+ }
422+ else
423+ {
424+ if ( cb -> status & fp09_status_inexact_result ) printf ( "INEXACT RESULT " );
425+ if ( cb -> status & fp09_status_undefined ) printf ( "UNDEFINED " );
426+ if ( cb -> status & fp09_status_integer_overflow ) printf ( "INT OVERFLOW " );
427+ if ( cb -> status & fp09_status_unordered ) printf ( "UNORDERED " );
428+ if ( cb -> status & fp09_status_division_zero ) printf ( "DIV BY 0 " );
429+ if ( cb -> status & fp09_status_underflow ) printf ( "UNDERFLOW " );
430+ if ( cb -> status & fp09_status_overflow ) printf ( "OVERFLOW " );
431+ if ( cb -> status & fp09_status_invalid_operation ) printf ( "INVALID " );
432+ printf ("\n" );
433+ }
432434
433435 cb -> status = 0 ;
434436 cb -> secondary_status = 0 ;
0 commit comments