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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6cf602b7ea8a1df1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-02-15 08:23:26 PST From: "Martin Dowie" Newsgroups: comp.lang.ada References: <3a8bbb84$1@pull.gecm.com> <3A8BF422.69723366@m_a_i_l.com> Subject: Re: Floating point accuracy Date: Thu, 15 Feb 2001 16:22:25 -0000 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: sg2ntw48151.dsge.edinbr.gmav.gecm.com Message-ID: <3a8c00a1$1@pull.gecm.com> X-Trace: 15 Feb 2001 16:15:29 GMT, sg2ntw48151.dsge.edinbr.gmav.gecm.com Path: supernews.google.com!sn-xit-02!supernews.com!isdnet!grolier!btnet-peer0!btnet-feed5!btnet!newreader.ukcore.bt.net!pull.gecm.com!sg2ntw48151.dsge.edinbr.gmav.gecm.com Xref: supernews.google.com comp.lang.ada:5277 Date: 2001-02-15T16:22:25+00:00 List-Id: doh! It's my eyes that don't have the necessary significant digits! As Markku points out, the values for "ls" _are_ different - just not where I had expected! In fact they are exactly 1000ns different, as I should have expected (the last 3 digits are the same, and confusing me!) But, Markku, the 'Floor is doing exactly what I want it to do... :-) "M. Kotiaho" wrote in message news:3A8BF422.69723366@m_a_i_l.com... > Martin Dowie wrote: > > Yes ... look more closely at your results ... the values you print for "ns" > differ in one digit (last non-zero digit). The values for "ls" are also > different > (the last value has ...66..., the previous one has ...65...). It is only for > "ms" > and "MS" that the values are the same. > > You should not expect otherwise, since you are losing information when > you take the 'floor operation in computing Float_MS. It has nothing to do > with the number of significant digits (since you have enough). > > Here is the math: > > 'Last - 1: > Float_MS = Floor( (2**32 - 2)*1000 / 2**32 ) = Floor( 1000 - 2000/2**32 ) = 999 > > 'Last: > Float_MS = Floor( (2**32 - 1)*1000 / 2**32 ) = Floor( 1000 - 1000/2**32 ) = 999 > > ...... > > > > > test 'Last - 1 > > ns = 4.29496729400000E+12 > > ms = 9.99000000000000E+02 > > MS = 4.29067232870400E+12 > > ls = 4.29496529600000E+09 > > > > ms => 999 ls => 4294965296 > > test 'Last > > ns = 4.29496729500000E+12 > > ms = 9.99000000000000E+02 > > MS = 4.29067232870400E+12 > > ls = 4.29496629600000E+09 > > > > ms => 999 ls => 4294966296 > > Regards, > Markku Kotiaho > > >