A N o t e on R a t i o n a l A r i t h m e t i c Peter Kornerup Computer Science Department Aarhus University, Denmark A r e c e n t p a p e r in S I G M I C R O [11 c o n t a i n e d a c o m p a r i s o n of the a c c u r a c y of f l o a t i n g p o i n t v s . r a t i o n a l r e p r e s e n t a t i o n s , w h i c h is v e r y u n f a i r to the l a t t e r . T h e f o r m a t c h o s e n f o r r a t i o n a l n u m b e r s u t i l i z e s 16 b i t s f o r n u m e r a t o r s and 16 b i t s f o r d e n o m i n a t o r s . This implies that the s p a c i n g b e t w e e n c o n s e c u t i v e n u m b e r s in the s y s t e m is in m o s t c a s e s of the o r d e r 27 3 2 . O n l y a r o u n d s i m p l e r a t i o n a l n u m b e r s ( e . g . 1 / 1 , 2 / 3 ) is the s p a c i n g of the o r d e r 2 - 1 6 . H o w e v e r the r o u n d i n g a l g o r i t h m p r e s e n t e d in [11 w i l l a l m o s t c e r t a i n l y i n t r o d u c e a r o u n d i n g e r r o r of t h e order 2-le i , e . i n t r o d u c e a n e r r o r w h i c h in m o s t c a s e s is of. t h e o r d e r 216 l a r g e r t h a n n e c e s s a r y . A l s o it is a s t a n d a r d r e q u i r e m e n t of a r o u n d i n g a l g o r i t h m t h a t w h e n e v e r a n u m b e r x is n o t r e p r e s e n t a b l e ~ the r o u n d e d v a l u e of x is t a k e n to be o n e of the t w o c l o s e s t r e p r e s e n t a b l e n u m b e r s . T h e a l g o r i t h m of E l l d o e s n o t s a t i s f y t h i s b a s i c p r o p e r t y of a r o u n d i n g . If t h i s p r o p e r t y is v i o l a t e d ~ a s an e x a m p l e f o r a > 0 and b > c, the r o u n d e d v a l u e of a X b - a x c c a n t u r n o u t to be n e g a t i v e s w h i c h may be v e r y s u r p r i s i n g to the u s e r . O n e w a y to be s u r e t h a t the r o u n d e d v a l u e is a l w a y s c h o s e n a s o n e of the n e a r e s t ( s u r r o u n d i n g ) n u m b e r s in the . n u m b e r s y s t e m s is to t r u n c a t e the c o n t i n u e d f r a c t i o n of the n u m b e r to be r o u n d e d . T h i s r o u n d e d v a l u e c a n be f o u n d by a n e x t e n d e d v e r s i o n of the E u c l i d i a n A l g o r i t h m s at p r a c t i c a l l y no e x t r a c o s t s s i n c e t h i s a l g o r i t h m is b e i n g u s e d a n y w a y in [11 tO d e t e r m i n e c o m m o n f a c t o r s . T h e r e a d e r is r e f e r r e d to [21 a n d [3~ f o r a m o r e d e t a i l e d d i s c u s s i o n of s u c h r a t i o n a l n u m b e r s y s t e m s and a s s o c i a t e d rounding. [11 W.I. Thacker & G.W. Gorsline, ~lMicro P r o g r a m m i n g R a t i o n a l A r i t h m e t i c O p e r a t i o n s n ~ S I G M I C R O V o l . 10 no. 1. M a t u l a 6' P . K o r n e r u p , " A F e a s i b i l i t y A n a l y s i s of B i n a r y Fixed-Slash and F l o a t i n g - S l a s h Number Systems", in P r o c e e d i n g s of the F o u r t h I E E E S y m p o s i u m on C o m p u t e r A r i t h m e t i c s O c t o b e r 19'78. [2] D.W. [33 P. K o r n e r u p 6" D . W . M a t u l a ~ IIA F e a s i b i l i t y A n a l y s i s of F i x e d - S l a s h Rational Arithmeticn~ in P r o c e e d i n g s of the F o u r t h I E E E S y m p o s i u m on C o m p u t e r A r i t h m e t i c , O c t o b e r 19'78.
/lp/association-for-computing-machinery/a-note-on-rational-arithmetic-IWH8QLZzKI