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,6a77269912f77a70 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-30 15:41:30 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!82-43-33-75.cable.ubr01.croy.blueyonder.co.UK!not-for-mail From: Nick Roberts Newsgroups: comp.lang.ada Subject: Re: Why no 'Floor for fixed point types Date: Thu, 30 Oct 2003 23:41:25 +0000 Message-ID: References: <3F99FBE1.1030601@comcast.net> NNTP-Posting-Host: 82-43-33-75.cable.ubr01.croy.blueyonder.co.uk (82.43.33.75) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1067557289 39354697 82.43.33.75 (16 [25716]) User-Agent: Mozilla/5.0 (Windows; U; Win95; en-US; rv:1.5) Gecko/20031013 Thunderbird/0.3 X-Accept-Language: en-us, en In-Reply-To: Xref: archiver1.google.com comp.lang.ada:1862 Date: 2003-10-30T23:41:25+00:00 List-Id: Randy Brukardt wrote: >>Do you think fixed point types should have a Floor attribute? > > The original answer to this showed that for some fixed point types, it > wouldn't be possible to implement it accurately. Thus, it is much better to > show what you are doing via a conversion to an appropriate float type. > Hopefully the compiler can note the easy cases and eliminate the float > operations. To my mind, I would not expect this form of optimisation in any compiler. Would it not be reasonable to provide 'Floor for fixed-point types which fulfil certain conditions? For example, it might be required that the delta be less than 1.0 (and that the range includes at least one integer). Alternatively, it might be required that the delta is precisely 1.0 (with conditions on the range). These conditions might be imposed statically (erroneous) or dynamically (raising an exception). I suppose the dynamic option would fit easier with the possibility of the fixed point type being a generic formal. After all, if Float'Floor(Float(X)) is going to produce a silly result (without itself raising Constraint_Error), what's wrong with Some_Fixed'Floor(X) raising Constraint_Error? Surely that would actually be better? -- Nick Roberts