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,16dbd7ecc6a3d50c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 05 May 2006 11:49:04 -0500 From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Ada decimal types References: X-Newsreader: Tom's custom newsreader Message-ID: Date: Fri, 05 May 2006 11:49:04 -0500 NNTP-Posting-Host: 67.169.16.3 X-Trace: sv3-6j7DJJkhyAHP/95auxgyPVWnLLkcTGOW+aKI4OtZtjnxuV3nTsrpK/+cKAXUkfbtMugvRbj4Me4c5KT!8xuFBngQs8Uf8ryUt4laKfkcPO/2fqjpY+nGmqnI5MtWsisKkVsoTNmCAOM1laZU3hRI1xHa0s0= X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.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: g2news2.google.com comp.lang.ada:4098 Date: 2006-05-05T11:49:04-05:00 List-Id: > A decimal type is a fixed pointed type. I don't want to use a binary fixed > point because it would change the precision. Currently any value of > microsecond granularity can be represented. If I use a binary fixed point, > that would change. I think you are expecting a fixed point decimal type to be stored in decimal notation. The value 1/10 could be stored precisely as "0.1", but 1/10 could not be stored precisely as a binary fraction. But that's not how Ada "fixed point", even decimal fixed point, works. "The set of values of a fixed point type comprise the integral multiples of a number called the 'small' of the type." ARM 3.5.9(8) The only difference between a decimal and an ordinary fixed point is that the 'small' for a decimal is a power of ten, while the 'small' for an ordinary is typically a power of two (unless you specify otherwise). Thus a decimal fixed point type with a delta of 1/10 would be stored, as integer multiples of 1/10. The value 1/10 would be stored as 1, with the implied scaling factor of "divide by 10". So type Mission_Time_Type is delta 1.0e-6 digits 16 range 0.0 .. (2.0**32) - 1.0; will store the number of microseconds. In effect your current record with two 32 bit integers is storing the same thing, it just stores (number of microseconds)/1_000_000 in one word and (number of microseconds) mod 1_000_000 in the other word, while type Mission_Time_Type would store (number of microseconds)/2**32 in its upper 32 bits and (number of microseconds) mod 2**32 in its upper 32 bits. Since all arithmetic is done conceptually as integers (the only difference is in how they are stored), they should give the same answers and the same precision.