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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,583275b6950bf4e6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-31 05:37:33 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!newshub.sdsu.edu!newsfeed2.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!harp.news.atl.earthlink.net!not-for-mail From: Marin David Condic Newsgroups: comp.lang.ada Subject: Re: Saturated Math Date: Sat, 31 May 2003 08:37:29 -0400 Organization: MindSpring Enterprises Message-ID: <3ED8A209.2070208@noplace.com> References: <3ECFF541.1010705@attbi.com> <3ED0B820.5050603@noplace.com> <3ED2096F.3020800@noplace.com> <3ED353BE.40605@noplace.com> <3ED4A323.3000909@noplace.com> <3ED5E8DE.8070308@noplace.com> <3ED7437E.5060607@noplace.com> NNTP-Posting-Host: d1.56.a0.7e Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Server-Date: 31 May 2003 12:37:33 GMT User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 (OEM-HPQ-PRS1C03) X-Accept-Language: en-us, en Xref: archiver1.google.com comp.lang.ada:38201 Date: 2003-05-31T12:37:33+00:00 List-Id: I don't understand what this would do. Is it essentially a function that is going to range limit what you pass in to be between the lower and upper bound? That isn't much help. What I *want* (and I don't seem to be making this clear, do I?) is to have a type whos behavior on overflow is to saturate rather than raise an exception. The idea is that if there is some kind of mistake or error in the logic or some other exceptional condition, the numbers saturate rather than stop the execution of the program. That's the critical part - don't be raising exceptions on me - saturate and try to press on and hope we don't blow up this thing we're controlling. Side benefits of the saturation might be that they have other uses - just like wraparound semantics on modular types can be useful for things like ring buffers. I don't really care that the math may be evaluation order dependent - math already *is* evaluation order dependent. I think it would be useful in spite of all the objections raised here because I've used it already. I just don't want to have to cobble together my own types. It would be better to have the compiler do it. MDC Dmitry A. Kazakov wrote: > > What about a numeric attribute: > > S'Saturate (X : T; L, R : ) > return ; > > for any subtype S of a floating point T gives X converted to universal > integer type. The result is always within [L, R]. > > (What would you do with NaN?) > -- ====================================================================== Marin David Condic I work for: http://www.belcan.com/ My project is: http://www.jast.mil/ Send Replies To: m c o n d i c @ a c m . o r g "In general the art of government consists in taking as much money as possible from one class of citizens to give to the other." -- Voltaire ======================================================================