Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,16 +0,0 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
with GNATCOLL.GMP; use GNATCOLL.GMP;
|
||||
with GNATCOLL.GMP.Integers; use GNATCOLL.GMP.Integers;
|
||||
procedure ArbitraryInt is
|
||||
type stracc is access String;
|
||||
BigInt : Big_Integer;
|
||||
len : Natural;
|
||||
str : stracc;
|
||||
begin
|
||||
Set (BigInt, 5);
|
||||
Raise_To_N (BigInt, Unsigned_Long (4**(3**2)));
|
||||
str := new String'(Image (BigInt));
|
||||
len := str'Length;
|
||||
Put_Line ("Size is:"& Natural'Image (len));
|
||||
Put_Line (str (1 .. 20) & "....." & str (len - 19 .. len));
|
||||
end ArbitraryInt;
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
identification division.
|
||||
program-id. arbitrary-precision-integers.
|
||||
remarks. Uses opaque libgmp internals that are built into libcob.
|
||||
|
||||
data division.
|
||||
working-storage section.
|
||||
01 gmp-number.
|
||||
05 mp-alloc usage binary-long.
|
||||
05 mp-size usage binary-long.
|
||||
05 mp-limb usage pointer.
|
||||
01 gmp-build.
|
||||
05 mp-alloc usage binary-long.
|
||||
05 mp-size usage binary-long.
|
||||
05 mp-limb usage pointer.
|
||||
|
||||
01 the-int usage binary-c-long unsigned.
|
||||
01 the-exponent usage binary-c-long unsigned.
|
||||
01 valid-exponent usage binary-long value 1.
|
||||
88 cant-use value 0 when set to false 1.
|
||||
|
||||
01 number-string usage pointer.
|
||||
01 number-length usage binary-long.
|
||||
|
||||
01 window-width constant as 20.
|
||||
01 limit-width usage binary-long.
|
||||
01 number-buffer pic x(window-width) based.
|
||||
|
||||
procedure division.
|
||||
arbitrary-main.
|
||||
|
||||
*> calculate 10 ** 19
|
||||
perform initialize-integers.
|
||||
display "10 ** 19 : " with no advancing
|
||||
move 10 to the-int
|
||||
move 19 to the-exponent
|
||||
perform raise-pow-accrete-exponent
|
||||
perform show-all-or-portion
|
||||
perform clean-up
|
||||
|
||||
*> calculate 12345 ** 9
|
||||
perform initialize-integers.
|
||||
display "12345 ** 9 : " with no advancing
|
||||
move 12345 to the-int
|
||||
move 9 to the-exponent
|
||||
perform raise-pow-accrete-exponent
|
||||
perform show-all-or-portion
|
||||
perform clean-up
|
||||
|
||||
*> calculate 5 ** 4 ** 3 ** 2
|
||||
perform initialize-integers.
|
||||
display "5 ** 4 ** 3 ** 2: " with no advancing
|
||||
move 3 to the-int
|
||||
move 2 to the-exponent
|
||||
perform raise-pow-accrete-exponent
|
||||
move 4 to the-int
|
||||
perform raise-pow-accrete-exponent
|
||||
move 5 to the-int
|
||||
perform raise-pow-accrete-exponent
|
||||
perform show-all-or-portion
|
||||
perform clean-up
|
||||
goback.
|
||||
*> **************************************************************
|
||||
|
||||
initialize-integers.
|
||||
call "__gmpz_init" using gmp-number returning omitted
|
||||
call "__gmpz_init" using gmp-build returning omitted
|
||||
.
|
||||
|
||||
raise-pow-accrete-exponent.
|
||||
*> check before using previously overflowed exponent intermediate
|
||||
if cant-use then
|
||||
display "Error: intermediate overflow occured at "
|
||||
the-exponent upon syserr
|
||||
goback
|
||||
end-if
|
||||
call "__gmpz_set_ui" using gmp-number by value 0
|
||||
returning omitted
|
||||
call "__gmpz_set_ui" using gmp-build by value the-int
|
||||
returning omitted
|
||||
call "__gmpz_pow_ui" using gmp-number gmp-build
|
||||
by value the-exponent
|
||||
returning omitted
|
||||
call "__gmpz_set_ui" using gmp-build by value 0
|
||||
returning omitted
|
||||
call "__gmpz_get_ui" using gmp-number returning the-exponent
|
||||
call "__gmpz_fits_ulong_p" using gmp-number
|
||||
returning valid-exponent
|
||||
.
|
||||
|
||||
*> get string representation, base 10
|
||||
show-all-or-portion.
|
||||
call "__gmpz_sizeinbase" using gmp-number
|
||||
by value 10
|
||||
returning number-length
|
||||
display "GMP length: " number-length ", " with no advancing
|
||||
|
||||
call "__gmpz_get_str" using null by value 10
|
||||
by reference gmp-number
|
||||
returning number-string
|
||||
call "strlen" using by value number-string
|
||||
returning number-length
|
||||
display "strlen: " number-length
|
||||
|
||||
*> slide based string across first and last of buffer
|
||||
move window-width to limit-width
|
||||
set address of number-buffer to number-string
|
||||
if number-length <= window-width then
|
||||
move number-length to limit-width
|
||||
display number-buffer(1:limit-width)
|
||||
else
|
||||
display number-buffer with no advancing
|
||||
subtract window-width from number-length
|
||||
move function max(0, number-length) to number-length
|
||||
if number-length <= window-width then
|
||||
move number-length to limit-width
|
||||
else
|
||||
display "..." with no advancing
|
||||
end-if
|
||||
set address of number-buffer up by
|
||||
function max(window-width, number-length)
|
||||
display number-buffer(1:limit-width)
|
||||
end-if
|
||||
.
|
||||
|
||||
clean-up.
|
||||
call "free" using by value number-string returning omitted
|
||||
call "__gmpz_clear" using gmp-number returning omitted
|
||||
call "__gmpz_clear" using gmp-build returning omitted
|
||||
set address of number-buffer to null
|
||||
set cant-use to false
|
||||
.
|
||||
|
||||
end program arbitrary-precision-integers.
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
(let* ((integer-width (* 65536 16)) ; raise bignum limit from 65536 bits to avoid overflow error
|
||||
(answer (number-to-string (expt 5 (expt 4 (expt 3 2)))))
|
||||
(length (length answer)))
|
||||
(message "%s has %d digits"
|
||||
(if (> length 40)
|
||||
(format "%s...%s"
|
||||
(substring answer 0 20)
|
||||
(substring answer (- length 20) length))
|
||||
answer)
|
||||
length))
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
(let* ((answer (calc-eval "5**4**3**2"))
|
||||
(length (length answer)))
|
||||
(message "%s has %d digits"
|
||||
(if (> length 40)
|
||||
(format "%s...%s"
|
||||
(substring answer 0 20)
|
||||
(substring answer (- length 20) length))
|
||||
answer)
|
||||
length))
|
||||
|
|
@ -1,17 +1,18 @@
|
|||
module checkit {
|
||||
z=4^(3^2)
|
||||
z1=z/1024-1
|
||||
m=Biginteger("5")
|
||||
with m, "ToString" as m.ToString
|
||||
p=Biginteger("1024")
|
||||
m=5u 'Biginteger("5")
|
||||
' with m, "ToString" as m.ToString
|
||||
p=1024u 'Biginteger("1024")
|
||||
method m, "intpower", p as m1
|
||||
m=m1
|
||||
for i=1 to z1
|
||||
method m1, "multiply", m as m
|
||||
? len(m.tostring), i
|
||||
' method m1, "multiply", m as m
|
||||
m*=m1
|
||||
print len(""+m), i ' len(m.tostring), i
|
||||
refresh
|
||||
next
|
||||
a=m.tostring
|
||||
a=""+m ' m.tostring
|
||||
Print left$(a, 20)+"..."+Right$(a,20)
|
||||
}
|
||||
checkit
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
local bigint = require "bigint"
|
||||
require "bignum"
|
||||
local fmt = require "fmt"
|
||||
|
||||
local p = bigint.new(3) ^ bigint.new(2)
|
||||
p = bigint.new(4) ^ p
|
||||
p = bigint.new(5) ^ p
|
||||
|
||||
local s = p:tostring()
|
||||
mpz.init()
|
||||
local s = mpz.tostring(p)
|
||||
fmt.print("5 ^ 4 ^ 3 ^ 2 has %s digits.\n", fmt.int(#s))
|
||||
print("The first twenty and last twenty are: ")
|
||||
print(fmt.abridge(s, 20))
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
# Perform calculation
|
||||
$BigNumber = [BigInt]::Pow( 5, [BigInt]::Pow( 4, [BigInt]::Pow( 3, 2 ) ) )
|
||||
|
||||
# Display first and last 20 digits
|
||||
$BigNumberString = [string]$BigNumber
|
||||
$BigNumberString.Substring( 0, 20 ) + "..." + $BigNumberString.Substring( $BigNumberString.Length - 20, 20 )
|
||||
|
||||
# Display number of digits
|
||||
$BigNumberString.Length
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
/*REXX program calculates and demonstrates arbitrary precision numbers (using powers). */
|
||||
numeric digits 200000 /*two hundred thousand decimal digits. */
|
||||
|
||||
# = 5 ** (4 ** (3 ** 2) ) /*calculate multiple exponentiations. */
|
||||
|
||||
true=62060698786608744707...92256259918212890625 /*what answer is supposed to look like.*/
|
||||
rexx= left(#, 20)'...'right(#, 20) /*the left and right 20 decimal digits.*/
|
||||
|
||||
say ' true:' true /*show what the "true" answer is. */
|
||||
say ' REXX:' rexx /* " " " REXX " " */
|
||||
say 'digits:' length(#) /* " " " length of answer is. */
|
||||
say
|
||||
if true == rexx then say 'passed!' /*either it passed, ··· */
|
||||
else say 'failed!' /* or it didn't. */
|
||||
/*stick a fork in it, we're all done. */
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
/*REXX program calculates and demonstrates arbitrary precision numbers (using powers). */
|
||||
numeric digits 5 /*just use enough digits for 1st time. */
|
||||
|
||||
#=5** (4** (3** 2) ) /*calculate multiple exponentiations. */
|
||||
|
||||
parse var # 'E' pow . /*POW might be null, so N is OK. */
|
||||
|
||||
if pow\=='' then do /*general case: POW might be < zero.*/
|
||||
numeric digits abs(pow) + 9 /*recalculate with more decimal digits.*/
|
||||
#=5** (4** (3** 2) ) /*calculate multiple exponentiations. */
|
||||
end /* [↑] calculation is the real McCoy. */
|
||||
|
||||
true=62060698786608744707...92256259918212890625 /*what answer is supposed to look like.*/
|
||||
rexx= left(#, 20)'...'right(#, 20) /*the left and right 20 decimal digits.*/
|
||||
|
||||
say ' true:' true /*show what the "true" answer is. */
|
||||
say ' REXX:' rexx /* " " " REXX " " */
|
||||
say 'digits:' length(#) /* " " " length of answer is. */
|
||||
say
|
||||
if true == rexx then say 'passed!' /*either it passed, ··· */
|
||||
else say 'failed!' /* or it didn't. */
|
||||
/*stick a fork in it, we're all done. */
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
set bigValue [expr {5**4**3**2}]
|
||||
puts "5**4**3**2 has [string length $bigValue] digits"
|
||||
if {[string match "62060698786608744707*92256259918212890625" $bigValue]} {
|
||||
puts "Value starts with 62060698786608744707, ends with 92256259918212890625"
|
||||
} else {
|
||||
puts "Value does not match 62060698786608744707...92256259918212890625"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue