M_big_integer(3fm) - [M_big_integer] define new data type BIG_INTEGER and operators
Synopsis
Description
Author
Example
use M_big_integer
The module named BIG_INTEGERS defines a new data type BIG_INTEGER. This data type represents nonnegative integers up to 10**n - 1, where n is the parameter (named constant) NR_OF_DECIMAL_DIGITS. This value may be changed, but the module must then be recompiled (it is not dynamic).
The following operations are implemented. "b" represents a big integer, "c" a character string, and "i" an ordinary integer.
big (i) big (c) int (b) int (c) char (b) char (i)Many operations of the form b ? i, where i < base, are implemented to be efficient as special cases.b = i b = c i = b i = c c = b c = i
b ? i, i ? b, and b ? b, where ? is +, -, *, /, <, <=, >, >=, ==, or /=
b ** i
modulo (b, i) [result is integer] modulo (i, b) [result is big_integer] modulo (b, b) [result is big_integer]
huge (b) sqrt (b)
call print_big (b) call random_number (b, low, high)
Copyright (c) 1993-2002 Unicomp, Inc.Developed at Unicomp, Inc.
Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved.
Sample program:
program demo_M_big_integer use M_big_integer type(big_integer) :: a, b a = "1234567890" b = a ** 34 call print_big(b) end program demo_M_big_integerExpected output:
18044389448552283571495419217299928002884571753268277623634094010253\ 66981452225691084844631888351415012575687866144963748904906312371105\ 80592001682129147574651845715171456148359301092015447205623057495772\ 65956402721330118223207623859033190068180607802717874097649095503332\ 13108684548203091283587744857909677706830329440243525585391247886790\ 67434454263656340662912379366253271751953736731074819372491000795297\ 39485301010583702548434613939308992953505848626082883004863432319153\ 74851257117575530170864942620865071745761606428864154243365627850016\ 44174485982226421972489721110767356064962137106505728778418700556641\ 02307658653980050645991117790555490389944390204219987434165392204913\ 97208851608204247050595317024494964141522065839042524403351250735123\ 55264351679192059781951740756716496372272101373104569806788535169770\ 01992757833390412200073266324230837178629444544469456556334359024793\ 85520866582032929720704074267136863063443220583328656131024989866204\ 73134625473086906778038872631750464721441869000000000000000000000000\ 00000000000000000000000000000000000000000000000000000000000000000000\ 0000000000000000000000000000000
Nemo Release 3.1 | M_big_integer (3) | February 23, 2025 |