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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.182.121.232 with SMTP id ln8mr3695967obb.11.1400887729331; Fri, 23 May 2014 16:28:49 -0700 (PDT) X-Received: by 10.50.44.37 with SMTP id b5mr157706igm.16.1400887729246; Fri, 23 May 2014 16:28:49 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!c1no15524465igq.0!news-out.google.com!qf4ni12380igc.0!nntp.google.com!c1no15524460igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 23 May 2014 16:28:48 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <1e869da6-f574-4873-8879-220f29f009c3@googlegroups.com> Subject: Re: Wrong Asignment From: Adam Beneschan Injection-Date: Fri, 23 May 2014 23:28:49 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:19997 Date: 2014-05-23T16:28:48-07:00 List-Id: On Friday, May 23, 2014 4:15:26 PM UTC-7, Cedric wrote: > Hi All, > > > > I am learning Ada since a few days. In my book is a simple excercise to write a program. It looks like this: > > with Text_IO; > with My_Int_IO; > with My_Flt_IO; > > ---------------------------------------------------------------------- > > procedure chapter2_programming_projects_1 is > Celsius : float := 0.0; > Fahrenheit : float := 0.0; > > begin > -- Input > Text_IO.Put("Please put in the temperature in Fahrenheit: "); > My_Flt_IO.Get(Item => Fahrenheit); > > -- Processing > > Celsius := (5/9) x (Fahrenheit - 32); The multiplication operator is * (asterisk), not "x". After you fix this, you will find other errors. Fahrenheit is a float, and 32 is an integer, and Ada doesn't like it when you mix operand types like that. You'll need to change the integers in this expression to floats, like this: Celsius := (5.0/9.0) * (Fahrenheit - 32.0); It's actually a good thing that Ada complains about it, because it prevents some misunderstandings. It is very common for new programmers learning C or C++ or Java to try celsius = (5/9) * (fahrenheit - 32); and then get on a help forum asking why does it keep outputting 0 for celsius? (It's because 5 and 9 are integers, so the program does integer division which throws away the remainder.) > Why does this statement result in an binary object? The error message said "binary operator", not "binary object". A binary operator is an operator like * that takes two operands. It was complaining because it expected a binary operator like *, but you gave it "x" which is an identifier. -- Adam