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-Thread: 103376,388fc53f584bd695 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Vinzent Hoefler" Newsgroups: comp.lang.ada Subject: Re: Fixed point constants issue Date: Wed, 15 Sep 2010 19:24:23 +0200 Message-ID: References: <1f0l0baynq1x7$.phl9cqpwcr37.dlg@40tude.net> <1ak1k4eh1p96t$.essf9fu1cx4z$.dlg@40tude.net> <1nlhu18d10l2j$.1o2b3qlrc5rki$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Trace: individual.net 1ZcF/ueOEpjRknQEryfkzgnmaXRcHwpry06bY5kbYH1JxA6ghD Cancel-Lock: sha1:Qc0JWSKr5IGmGfhgdOB2q90pWEI= User-Agent: Opera Mail/10.62 (Win32) Xref: g2news1.google.com comp.lang.ada:14092 Date: 2010-09-15T19:24:23+02:00 List-Id: On Wed, 15 Sep 2010 10:35:22 +0200, Dmitry A. Kazakov wrote: > On Tue, 14 Sep 2010 19:42:52 +0200, Vinzent Hoefler wrote: > >> -- 8< -- snip -- >> type BASE_TYPE is delta 1.0 / 64.0 range 0.0 .. 1.0; >> for BASE_TYPE'Small use 1.0 / 128.0; > > But use suggests rather: > > type Base_Type is delta 0.01 digits 3 range 0.0..1.0; > > or > > type Base_Type is delta 0.01 digits 3 range -1.0..1.0; No. These are bus-protocol types (read: hardware types) where MSB values, bit sizes and (valid) range are given, so we definitely want to make sure that the compiler uses the correct representation. Thus, a "simple" digits constraint is ruled out here. Usually such a type definition looks similar to that: type Foo is delta 1.638_400 / 2**13 range -0.819_200 .. 0.819_200; for Foo'Small use 1.638_400 / 2**13; for Foo'Size use 13; For reading from the bus we use the (full-range) base type and checking its range before assigning it to the appropriate object of the constrained subtype. Vinzent. -- There is no signature.