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,d0715d5e4ba7908b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Wed, 16 Mar 2005 16:34:17 -0600 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: <1110998197.165590.63800@z14g2000cwz.googlegroups.com> Subject: Re: Fixed point attributes Date: Wed, 16 Mar 2005 16:36:35 -0600 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4927.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-nnHbfjmE16C+YlxKqSKawgcetf9Md/0LPwAT6GQZj4znNOag7loRIc6tia3WPHHT1QfwvXVqSqlo2lE!oeydubFNeHOCvF5QIVgumu7yUf7RMms+MJ3GFmmfaobThPu4MydInmzkWYUCWq/dnqTgPPWGiuvY X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news1.google.com comp.lang.ada:9524 Date: 2005-03-16T16:36:35-06:00 List-Id: wrote in message news:1110998197.165590.63800@z14g2000cwz.googlegroups.com... > I do not understand why Ada fixed point types have the Round attribute > but not Floor or Truncation. Adding the later two would make fixed > point types more useful, and reduce the need for type conversions. Ada fixed point types don't have "Round"; that's only available for decimal types (intended primarily to be used for money). I don't know what the thinking was for omitting Truncation for decimal types; perhaps Bob knows. In general, you can't have attributes like that for fixed point types, because there is no requirement that the a fixed point type can represent integers. For instance, if you have: type Weird_Fixed delta 0.77 range 0 .. 100.0; for Weird_Fixed'Small use 0.77; the only integers that can be represented exactly are 0 and 77. So what would Round or Truncation mean for that sort of type? What is the result of Weird_Fixed'Truncation (20.5)? The closest value smaller than 20 is 19.25. That doesn't seem to be a sensible result to me. This of course is a case where Ada's generality gets in the way. It would be nice to have such attributes, but it would mean outlawing arbitrary small values. I don't think smalls like this are used much, but it would be incompatible, and there would be no real workaround if such smalls were outlawed. (You'd have to switch to floating point, or write your own pseudo-fixed package.) I think that would be too much of an incompatibility. (Note that only allowing the attributes on some fixed point types would be a generic contract model violation, so that isn't a viable solution, either.) Randy.