Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,6 +0,0 @@
|
|||
generic
|
||||
type Real is digits <>;
|
||||
procedure Real_To_Rational(R: Real;
|
||||
Bound: Positive;
|
||||
Nominator: out Integer;
|
||||
Denominator: out Positive);
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
procedure Real_To_Rational (R: Real;
|
||||
Bound: Positive;
|
||||
Nominator: out Integer;
|
||||
Denominator: out Positive) is
|
||||
Error: Real;
|
||||
Best: Positive := 1;
|
||||
Best_Error: Real := Real'Last;
|
||||
begin
|
||||
if R = 0.0 then
|
||||
Nominator := 0;
|
||||
Denominator := 1;
|
||||
return;
|
||||
elsif R < 0.0 then
|
||||
Real_To_Rational(-R, Bound, Nominator, Denominator);
|
||||
Nominator := - Nominator;
|
||||
return;
|
||||
else
|
||||
for I in 1 .. Bound loop
|
||||
Error := abs(Real(I) * R - Real'Rounding(Real(I) * R));
|
||||
if Error < Best_Error then
|
||||
Best := I;
|
||||
Best_Error := Error;
|
||||
end if;
|
||||
end loop;
|
||||
end if;
|
||||
Denominator := Best;
|
||||
Nominator := Integer(Real'Rounding(Real(Denominator) * R));
|
||||
|
||||
end Real_To_Rational;
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
with Ada.Text_IO; With Real_To_Rational;
|
||||
|
||||
procedure Convert_Decimal_To_Rational is
|
||||
|
||||
type My_Real is new Long_Float; -- change this for another "Real" type
|
||||
|
||||
package FIO is new Ada.Text_IO.Float_IO(My_Real);
|
||||
procedure R2R is new Real_To_Rational(My_Real);
|
||||
|
||||
Nom, Denom: Integer;
|
||||
R: My_Real;
|
||||
|
||||
begin
|
||||
loop
|
||||
Ada.Text_IO.New_Line;
|
||||
FIO.Get(R);
|
||||
FIO.Put(R, Fore => 2, Aft => 9, Exp => 0);
|
||||
exit when R = 0.0;
|
||||
for I in 0 .. 4 loop
|
||||
R2R(R, 10**I, Nom, Denom);
|
||||
Ada.Text_IO.Put(" " & Integer'Image(Nom) &
|
||||
" /" & Integer'Image(Denom));
|
||||
end loop;
|
||||
end loop;
|
||||
end Convert_Decimal_To_Rational;
|
||||
Loading…
Add table
Add a link
Reference in a new issue