From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: getting same output as gfortran, long_float
Date: Thu, 30 Apr 2015 18:16:52 -0700
Date: 2015-04-30T18:16:52-07:00 [thread overview]
Message-ID: <mhuk46$nd5$1@dont-email.me> (raw)
In-Reply-To: <mhuai0$249$1@speranza.aioe.org>
On 04/30/2015 03:32 PM, Nasser M. Abbasi wrote:
>
> With Ada.Text_IO;
> with system;
> procedure Foo_However_Many is
> type Big is digits System.Max_Digits;
> X : Big := 12.0 * 0.0001 / (1.0 * (1.0 - 0.1) ** 4);
> begin -- Foo_However_Many
> Ada.Text_IO.Put_Line (Item => X'Img);
> end Foo_However_Many;
>
> ./foo_however_many
> 1.82898948331047096E-03
You could always do
with Ada.Text_IO;
with PragmARC.Rational_Numbers;
with PragmARC.Unbounded_Integers;
procedure Foo_Rational is
use PragmARC;
use type Rational_Numbers.Rational;
use type Unbounded_Integers.Unbounded_Integer;
One_I : constant Unbounded_Integers.Unbounded_Integer := +1;
Twelve : constant Rational_Numbers.Rational := Unbounded_Integers."+" (12) /
One_I;
P0001 : constant Rational_Numbers.Rational := One_I / (+10_000); -- 0.0001
P1 : constant Rational_Numbers.Rational := One_I / (+10); -- 0.1
One : Rational_Numbers.Rational renames Rational_Numbers.One;
Result : constant Rational_Numbers.Rational := Twelve * P0001 / (One * (One -
P1) ** 4);
begin -- Foo_Rational
Ada.Text_IO.Put_Line (Item => Rational_Numbers.Image (Result) );
end Foo_Rational;
$ gnatmake -gnatano -gnatwa -O2 -fstack-check -I../RAC foo_rational.adb
gcc-4.6 -c -gnatano -gnatwa -O2 -fstack-check -I../RAC foo_rational.adb
gnatbind -I../RAC -x foo_rational.ali
gnatlink foo_rational.ali -O2 -fstack-check
jrcarter@jcarter-singo-laptop:~/Code$ ./foo_rational
0.0018289894833104709647919524462734339277549154092363968907178783721993598536808413351623228166438042981252857796067672610882487425697302240512117055326931870141746684956561499771376314586191129401005944215820759030635573845450388660265203475080018289894833104709647919524462734339277549154092363968907178783721993598536808413351623228166438042981252857796067672610882487425697302240512117055326931870141746684956561499771376314586191129401005944215820759030635573845450388660265203475080018289894833104709647919524462734339277549154092363968907178783721993598536808413351623228166438042981252857796067672610882487425697302240512117055326931870141746684956561499771376314586191129401005944215820759030635573845450388660265203475080018289894833104709647919524462734339277549154092363968907178783721993598536808413351623228166438042981252857796067672610882487425697302240512117055326931870141746684956561499771376314586191129401005944215820759030635573845450388660265203475080018289894833104709647919
524462
The referenced PragmARC pkgs are available in the beta version of the PragmAda
Reusable Components available from
https://pragmada.x10hosting.com/pragmarc.htm
--
Jeff Carter
"Many times we're given rhymes that are quite unsingable."
Monty Python and the Holy Grail
57
next prev parent reply other threads:[~2015-05-01 1:16 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-30 21:17 getting same output as gfortran, long_float Nasser M. Abbasi
2015-04-30 22:08 ` Dmitry A. Kazakov
2015-04-30 22:11 ` Dmitry A. Kazakov
2015-04-30 22:37 ` Nasser M. Abbasi
2015-04-30 22:53 ` Nasser M. Abbasi
2015-05-01 7:22 ` Jacob Sparre Andersen
2015-05-01 1:12 ` Nasser M. Abbasi
2015-05-01 6:52 ` Dmitry A. Kazakov
2015-05-01 7:32 ` Nasser M. Abbasi
2015-05-01 7:45 ` Dmitry A. Kazakov
2015-05-04 0:15 ` robin.vowels
2015-05-04 7:21 ` Dmitry A. Kazakov
2015-05-04 8:53 ` robin.vowels
2015-05-04 10:18 ` Dmitry A. Kazakov
2015-05-04 13:45 ` robin.vowels
2015-05-04 14:47 ` Dmitry A. Kazakov
2015-05-07 2:01 ` robin.vowels
2015-05-01 23:24 ` Dennis Lee Bieber
2015-05-04 0:09 ` robin.vowels
2015-05-01 7:01 ` Dmitry A. Kazakov
2015-05-04 0:42 ` robin.vowels
2015-04-30 22:12 ` Jeffrey R. Carter
2015-04-30 22:27 ` Qun-Ying
2015-05-01 0:59 ` Dennis Lee Bieber
2015-04-30 22:32 ` Nasser M. Abbasi
2015-05-01 1:16 ` Jeffrey R. Carter [this message]
2015-05-01 1:40 ` Nasser M. Abbasi
2015-05-01 7:47 ` Jacob Sparre Andersen
2015-05-01 15:39 ` Waldek Hebisch
2015-05-01 17:27 ` Nasser M. Abbasi
2015-05-01 18:03 ` Nasser M. Abbasi
2015-05-04 0:51 ` robin.vowels
2015-05-04 0:47 ` robin.vowels
2015-05-01 8:21 ` Simon Wright
2015-05-01 11:55 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox