From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on ip-172-31-74-118.ec2.internal X-Spam-Level: * X-Spam-Status: No, score=1.0 required=3.0 tests=BAYES_40,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?Q?Bj=c3=b6rn_Lundin?= Newsgroups: comp.lang.ada Subject: Re: Fixed vs float and precision and conversions Date: Wed, 8 Jul 2020 10:17:08 +0200 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Wed, 8 Jul 2020 08:17:08 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="bbc4443e166da1163e3df9d7300a854c"; logging-data="20874"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+sG8leFGo+DkqRpV16QvxT" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 Cancel-Lock: sha1:X6FT7GZpX12UOVXdqn4x6GHBUvg= In-Reply-To: Content-Language: sv Xref: reader01.eternal-september.org comp.lang.ada:59393 List-Id: Den 2020-07-07 kl. 23:30, skrev Niklas Holsti: > > According to RM 4.6(31), conversion to a decimal fixed-point type does > not round, but truncates toward zero if the operand is not a multiple of > the "small" of the target type, which is usually the case here if Floats > are base-two. > > You should perhaps change the conversion (Target := Fixed_Type(Tmp)) to > round, by doing Target := Fixed_Point'Round (Tmp). > > Note, I haven't tried it. Ok - nice idea. I'll try it, thanks. -- Björn