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.107.151.76 with SMTP id z73mr5023658iod.70.1516815900235; Wed, 24 Jan 2018 09:45:00 -0800 (PST) X-Received: by 10.157.31.57 with SMTP id x54mr713104otd.1.1516815900166; Wed, 24 Jan 2018 09:45:00 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.linkpendium.com!news.linkpendium.com!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!w142no159679ita.0!news-out.google.com!b73ni9685ita.0!nntp.google.com!w142no159678ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 24 Jan 2018 09:44:59 -0800 (PST) In-Reply-To: <3d796e5f-015e-469c-bbcb-edc3303793ab@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:191:8303:2100:7466:f44c:da21:40b1; posting-account=fdRd8woAAADTIlxCu9FgvDrUK4wPzvy3 NNTP-Posting-Host: 2601:191:8303:2100:7466:f44c:da21:40b1 References: <3d796e5f-015e-469c-bbcb-edc3303793ab@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: no + or - defined for fixed point types in Standard, why ? From: Robert Eachus Injection-Date: Wed, 24 Jan 2018 17:45:00 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:50110 Date: 2018-01-24T09:44:59-08:00 List-Id: On Wednesday, January 24, 2018 at 12:03:40 PM UTC-5, Mehdi Saada wrote: > I have to define the addition, substraction and multiplication operators = for a fixed point real type, and (though I KNOW you don't do, that, but pas= s use a parent type whose primitives have not been overrided) I tried to pr= efix by "Standard" to see what happens. I thought it would just not work. The easy way to "get" Ada fixed point is that it is an integer type with a = predefined scaling factor, 'Small. The predefined operators include +, - = multiplication or division by an integer (which returns a value of the type= ), and the comparison operators which return Boolean. Division of two val= ues of the type, returning Integer could also be provided but isn't. There are special multiplication and division operators which are defined f= or any two fixed point types, and return a value which must be converted to= some type. Note that division operations are the only ones that can resul= t in rounding. Obviously this is important when you want to minimize round= ing. As for your problem.the compiler is trying to be nice, and confusing you. = It is hard to correctly override the predefined operators where they are di= rectly visible. If you can do the overriding where they are use visible th= at works, except for the magic versions of multiply and divide (that do not= have an integer parameter). To (re-)define * or / you will need to write = a body that uses Unchecked_Conversion of the proper integer type, or conver= ts both operands to some floating point type. As for the warnings? You are trying to do something wonky, and the compile= r is telling you that. If you really want to do it, consider turning warni= ngs off in the appropriate area.