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,9ce095aba33fe8d0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!proxad.net!infeed-2.proxad.net!news10-e.free.fr!not-for-mail Sender: sam@willow.rfc1149.net From: Samuel Tardieu Newsgroups: comp.lang.ada Subject: Re: Negative float problem References: <1130351574.313991.229420@g14g2000cwa.googlegroups.com> Date: 26 Oct 2005 21:05:42 +0200 Message-ID: <87vezk5cah.fsf@willow.rfc1149.net> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Leafnode-NNTP-Posting-Host: 2001:660:330f:f810:211:2fff:fea6:3aa1 Organization: Guest of ProXad - France NNTP-Posting-Date: 26 Oct 2005 21:06:00 MEST NNTP-Posting-Host: 81.56.47.149 X-Trace: 1130353560 news10-e.free.fr 12746 81.56.47.149:57808 X-Complaints-To: abuse@proxad.net Xref: g2news1.google.com comp.lang.ada:5963 Date: 2005-10-26T21:06:00+02:00 List-Id: >>>>> "Luke" == Luke writes: Luke> If 2 works then why doesnt the original? The same is true for Luke> +1.0. Is this a fault with gcc? No. In your first attempt X : file1.My_Float := -1.0; you are trying to use the "-" operator on the My_Float type. The operator is not immediately visible as it is defined in the file1 package. In the second attempt X : file1.My_Float := file1.My_Float (-1.0); you are in fact converting the Universal_Float value "-1.0" (which is obtained after having applied the unary "-" operator on the Universal_Float value "1.0", and this operator is always visible) to type My_Float. In fact, it is equivalent to writing Y : constant := -1.0; X : file1.My_Float := Y; If you look at Ada95 grammar (in Annex P if I remember correctly), you will see that numbers are defined *without* any leading "+" and "-" signs. Each time you write "-xxx", you apply the unary "-" operator to "xxx". Note that you could have written also X : file1.My_Float := file1."-" (1.0); I think that almost any Ada-er has learnt this rule the hard way one day or another :) Sam -- Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/sam