From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,51d2a071b516bbfb X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,5f2354778c35ff45 X-Google-Attributes: gid103376,public From: Markus Kuhn Subject: Re: Saturated Arithmetic Date: 1998/06/19 Message-ID: <358AA520.675C8EF@cl.cam.ac.uk>#1/1 X-Deja-AN: 364249549 Content-Transfer-Encoding: 7bit References: <358510A8.5E62@dmu.ac.uk> <6m6vkp$8un@gurney.reilly.home> <358A9962.2CE4EE98@elca-matrix.ch> Content-Type: text/plain; charset=us-ascii Organization: Cambridge University, Computer Laboratory Mime-Version: 1.0 Newsgroups: comp.lang.eiffel,comp.lang.ada Date: 1998-06-19T00:00:00+00:00 List-Id: Mats Weber wrote: > What is a saturating type ? Saturated/saturating arithmetic is a variant of integer or fixed-point arithmetic in which T'Last + 1 = T'Last T'First - 1 = T'First etc., i.e. where overflows and underflows of computations result in the closest representable value, and not in a wraparound or exception. Such types are *very* widely used in digital signal processing. If your result in an audio filter algorithm happens to be slightly above 16#ffff#, then the output you want is 16#ffff# as the closest possible approximation to the real result and you clearly do not want a wraparound to 16#0000# or an exception or extra code that has to take care of this in inner loops. Most DSPs as well as the new Intel MMX instructions provide hardware support for saturated arithmetic. I guess, adding saturated integer and fixed point types to Ada0X would be a sensible idea (at least if there will be a digital signal processing special annex). Markus -- Markus G. Kuhn, Security Group, Computer Lab, Cambridge University, UK email: mkuhn at acm.org, home page: