Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,15 +0,0 @@
|
|||
package Integer_Exponentiation is
|
||||
-- int^int
|
||||
procedure Exponentiate (Argument : in Integer;
|
||||
Exponent : in Natural;
|
||||
Result : out Integer);
|
||||
function "**" (Left : Integer;
|
||||
Right : Natural) return Integer;
|
||||
|
||||
-- real^int
|
||||
procedure Exponentiate (Argument : in Float;
|
||||
Exponent : in Integer;
|
||||
Result : out Float);
|
||||
function "**" (Left : Float;
|
||||
Right : Integer) return Float;
|
||||
end Integer_Exponentiation;
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
with Ada.Float_Text_IO, Ada.Integer_Text_IO, Ada.Text_IO;
|
||||
with Integer_Exponentiation;
|
||||
|
||||
procedure Test_Integer_Exponentiation is
|
||||
use Ada.Float_Text_IO, Ada.Integer_Text_IO, Ada.Text_IO;
|
||||
use Integer_Exponentiation;
|
||||
R : Float;
|
||||
I : Integer;
|
||||
begin
|
||||
Exponentiate (Argument => 2.5, Exponent => 3, Result => R);
|
||||
Put ("2.5 ^ 3 = ");
|
||||
Put (R, Fore => 2, Aft => 4, Exp => 0);
|
||||
New_Line;
|
||||
|
||||
Exponentiate (Argument => -12, Exponent => 3, Result => I);
|
||||
Put ("-12 ^ 3 = ");
|
||||
Put (I, Width => 7);
|
||||
New_Line;
|
||||
end Test_Integer_Exponentiation;
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
package body Integer_Exponentiation is
|
||||
-- int^int
|
||||
procedure Exponentiate (Argument : in Integer;
|
||||
Exponent : in Natural;
|
||||
Result : out Integer) is
|
||||
begin
|
||||
Result := 1;
|
||||
for Counter in 1 .. Exponent loop
|
||||
Result := Result * Argument;
|
||||
end loop;
|
||||
end Exponentiate;
|
||||
|
||||
function "**" (Left : Integer;
|
||||
Right : Natural) return Integer is
|
||||
Result : Integer;
|
||||
begin
|
||||
Exponentiate (Argument => Left,
|
||||
Exponent => Right,
|
||||
Result => Result);
|
||||
return Result;
|
||||
end "**";
|
||||
|
||||
-- real^int
|
||||
procedure Exponentiate (Argument : in Float;
|
||||
Exponent : in Integer;
|
||||
Result : out Float) is
|
||||
begin
|
||||
Result := 1.0;
|
||||
if Exponent < 0 then
|
||||
for Counter in Exponent .. -1 loop
|
||||
Result := Result / Argument;
|
||||
end loop;
|
||||
else
|
||||
for Counter in 1 .. Exponent loop
|
||||
Result := Result * Argument;
|
||||
end loop;
|
||||
end if;
|
||||
end Exponentiate;
|
||||
|
||||
function "**" (Left : Float;
|
||||
Right : Integer) return Float is
|
||||
Result : Float;
|
||||
begin
|
||||
Exponentiate (Argument => Left,
|
||||
Exponent => Right,
|
||||
Result => Result);
|
||||
return Result;
|
||||
end "**";
|
||||
end Integer_Exponentiation;
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
func mypow n exp .
|
||||
r = 1
|
||||
if exp < 0
|
||||
exp = -exp
|
||||
n = 1 / n
|
||||
.
|
||||
for i to exp
|
||||
r *= n
|
||||
.
|
||||
r = 1
|
||||
for i to exp : r *= n
|
||||
return r
|
||||
.
|
||||
print mypow pi 2
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
function pow($a, [int]$b) {
|
||||
if ($b -eq -1) { return 1/$a }
|
||||
if ($b -eq 0) { return 1 }
|
||||
if ($b -eq 1) { return $a }
|
||||
if ($b -lt 0) {
|
||||
$rec = $true # reciprocal needed
|
||||
$b = -$b
|
||||
}
|
||||
|
||||
$result = $a
|
||||
2..$b | ForEach-Object {
|
||||
$result *= $a
|
||||
}
|
||||
|
||||
if ($rec) {
|
||||
return 1/$result
|
||||
} else {
|
||||
return $result
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
Function pow(x,y)
|
||||
pow = 1
|
||||
If y < 0 Then
|
||||
For i = 1 To Abs(y)
|
||||
pow = pow * (1/x)
|
||||
Next
|
||||
Else
|
||||
For i = 1 To y
|
||||
pow = pow * x
|
||||
Next
|
||||
End If
|
||||
End Function
|
||||
|
||||
WScript.StdOut.Write "2 ^ 0 = " & pow(2,0)
|
||||
WScript.StdOut.WriteLine
|
||||
WScript.StdOut.Write "7 ^ 6 = " & pow(7,6)
|
||||
WScript.StdOut.WriteLine
|
||||
WScript.StdOut.Write "3.14159265359 ^ 9 = " & pow(3.14159265359,9)
|
||||
WScript.StdOut.WriteLine
|
||||
WScript.StdOut.Write "4 ^ -6 = " & pow(4,-6)
|
||||
WScript.StdOut.WriteLine
|
||||
WScript.StdOut.Write "-3 ^ 5 = " & pow(-3,5)
|
||||
WScript.StdOut.WriteLine
|
||||
Loading…
Add table
Add a link
Reference in a new issue