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!news4.google.com!news.glorb.com!atl-c03.usenetserver.com!news.usenetserver.com!news-rtr.nyroc.rr.com!news-out.nyroc.rr.com!twister.nyroc.rr.com.POSTED!53ab2750!not-for-mail From: "REH" Newsgroups: comp.lang.ada References: Subject: Re: Ada decimal types X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 X-RFC2646: Format=Flowed; Original Message-ID: Date: Fri, 05 May 2006 18:08:52 GMT NNTP-Posting-Host: 69.205.134.80 X-Complaints-To: abuse@rr.com X-Trace: twister.nyroc.rr.com 1146852532 69.205.134.80 (Fri, 05 May 2006 14:08:52 EDT) NNTP-Posting-Date: Fri, 05 May 2006 14:08:52 EDT Organization: Road Runner Xref: g2news2.google.com comp.lang.ada:4099 Date: 2006-05-05T18:08:52+00:00 List-Id: wrote in message news:ZcKdnZAJrtSdH8bZRVn-jQ@comcast.com... >> 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. I do know how fixed points "work." You are making assumptions about my expectations and the standard. Both of which are wrong. The internal of the decimal type are not defined by the standard. It could be stored at integers; it could be BCD. I personally don't care how it is stored. I just know that Ada guarantees me that if my delta is 1.0e6, it can represent every multiple of it within my range. You can specualate all you want about how it "works." I just care that it does. REH