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-24 14:46:18 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: Fri, 24 Oct 2003 22:46:14 +0100 Message-ID: References: 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 1067031977 32797092 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:1630 Date: 2003-10-24T22:46:14+01:00 List-Id: Duncan Sands wrote: > I think the subject says it all. Just curious. > > Duncan. For a fixed point type Tf -- assuming it has a delta which is less than 1 -- you can write: Scale: constant := 1/Tf'Small; type Ti is range Tf'First*Scale .. Tf'Last*Scale; function Scaled_Floor (X: in Tf) return Ti is begin return Ti(X*Scale) - Ti(X*Scale) mod Ti(Scale); end; The basic idea is that with fixed point types, a 'floor' function will inevitably need to be scaled, and the integer type it returns needs to be customised to the fixed point type (its range and delta) and the chosen scale. I've shown a scale of 1/Tf'Small, but the chances are that the scale you will require in a certain situation will be different (it might be unity). A little more information about your specific problem would enable us to give a more detailed diagnosis. -- Nick Roberts