From: garym@telesoft.UUCP (Gary Morris @flash)
Subject: Re: Ada decimal math, an example (or counterexample)
Date: 6 Jul 88 18:48:55 GMT [thread overview]
Message-ID: <8807071558.AA22454@ucsd.edu> (raw)
>
> type dollar_type is delta 0.01 range 0.00..1000.00;
> ...
> my_dime : dollar_type :=
> 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01;
> ...
These calculations are done using the dollar_type which has a 'small of
0.0078125. For the use you are making of this type, you should use a rep
spec to make 'small be the same as the delta. The TeleSoft TeleGen2
compiler supports this:
type dollar_type is delta 0.01 range 0.00..1000.00;
for dollar_type'small use 0.01;
With the rep spec our Sun Ada 1.1 compiler produces the "expected" results:
-- my_dime is worth 0.10
--your_dime is worth 0.10
Without the rep spec our Sun Ada 1.1 compiler does the computation using
a 'small of 0.0078125 yielding 0.078125, which is rounded to 0.08 for
output:
-- my_dime is worth 0.08
--your_dime is worth 0.08
Gary Morris UUCP: ucbvax!ucsd!telesoft!garym
TeleSoft, San Diego telesoft!garym@ucsd.edu
(619) 457-2700 ARPA: ucsd!telesoft!garym@ucbvax.ARPA
next reply other threads:[~1988-07-06 18:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1988-07-06 18:48 Gary Morris @flash [this message]
-- strict thread matches above, loose matches on Subject: below --
1988-07-01 17:54 Ada decimal math, an example (or counterexample) Norman Cohen
1988-06-30 21:53 CONTR47
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox