comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Fixed-point question
Date: Fri, 26 Jun 2015 21:44:04 -0700
Date: 2015-06-26T21:44:04-07:00	[thread overview]
Message-ID: <mml9k2$pvf$1@dont-email.me> (raw)
In-Reply-To: <21e4185b-bc89-4940-b329-09863ad17344@googlegroups.com>

On 06/26/2015 08:00 PM, Patrick Noffke wrote:
> On Friday, June 26, 2015 at 6:13:11 PM UTC-5, qunying wrote:
>> In my test with Linux x86_64 with FSF GNAT 4.9.2
>>
>> C1 :=  14.664
>> C2 :=  17.000
>> Small :=  3.90625000000000000E-03
>> 1/180 :=  5.55555555555555556E-03
>>
>> With Jeffrey's changes I got:
>> C1 :=  14.667
>> C2 :=  18.000
>> Small :=  5.55555555555555556E-03
>> 1/180 :=  5.55555555555555556E-03
>>
> 
> So is this a bug, is the ARM not clear on what should happen here, or is it expected?

With a small of 1/180:

For C1, AFAICT, the compiler will calculate N/D exactly, getting 44/3 =
14.6666...., and then convert this to Fixed_type, getting 2640/180.

For C2, "/" for Fixed_Type is used, so N and D are converted to Fixed_Type
first. N = 0.2 = 36/180, and D = 0.013636... is closest to 2/180 = 0.0111...
(36/180)/(2/180) = 36/2 = 18.

Working out the expected result for the default small of 1/256 is left as an
exercise for the reader.

-- 
Jeff Carter
"I did not rob a bank. If I'd robbed a bank, everything
would be great. I tried to rob a bank, is what happened,
and they got me."
Take the Money and Run
139


  reply	other threads:[~2015-06-27  4:44 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-26 13:20 Fixed-point question Patrick Noffke
2015-06-26 16:56 ` Jeffrey R. Carter
2015-06-26 18:21   ` Patrick Noffke
2015-06-26 20:21     ` Anh Vo
2015-06-26 20:25     ` Jeffrey R. Carter
2015-06-27  2:55       ` Patrick Noffke
2015-06-26 23:14     ` Qun-Ying
2015-06-27  3:00       ` Patrick Noffke
2015-06-27  4:44         ` Jeffrey R. Carter [this message]
2015-06-27 17:59           ` Patrick Noffke
2015-06-27 18:38             ` Jeffrey R. Carter
2015-06-27 19:20               ` Bob Duff
2015-06-27 19:57                 ` Jeffrey R. Carter
2015-06-27 20:42                   ` Bob Duff
2015-06-28 11:39                     ` Brian Drummond
2015-06-29 13:28                     ` Patrick Noffke
2015-06-29 14:13                       ` Bob Duff
2015-06-27 23:41               ` Anh Vo
  -- strict thread matches above, loose matches on Subject: below --
1995-04-01  0:00 Garlington KE
1995-04-06  0:00 ` Robert Dewar
1995-04-07  0:00   ` Robert I. Eachus
1995-04-07  0:00     ` Robert Dewar
1995-04-07  0:00   ` Garlington KE
1995-04-07  0:00     ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox