BigInt
.. BigInt(x)
Create an arbitrary precision integer. ``x`` may be an ``Int`` (or anything
that can be converted to an ``Int``). The usual mathematical operators are
defined for this type, and results are promoted to a ``BigInt``.
Instances can be constructed from strings via :func:`parse`, or using the
``big`` string literal.
Examples
In the Julia programming language, the BigInt(x)
function is used to create arbitrary precision integers. The argument x
can be an Int
or anything that can be converted to an Int
. The usual mathematical operators are defined for this type, and results are automatically promoted to BigInt
.
Here are some examples of using the BigInt
function:
-
Create a
BigInt
from anInt
:julia> a = BigInt(10) 10
In this example, we create a
BigInt
with the value 10 from anInt
. -
Perform arithmetic operations with
BigInt
:julia> a = BigInt(10) 10 julia> b = BigInt(5) 5 julia> c = a + b 15
Here, we perform addition on two
BigInt
numbersa
andb
, and store the result inc
. -
Create a
BigInt
from a string usingparse
:julia> str = "12345678901234567890" "12345678901234567890" julia> a = parse(BigInt, str) 12345678901234567890
This example demonstrates how to create a
BigInt
from a string using theparse
function. - Create a
BigInt
using thebig
string literal:julia> a = big"12345678901234567890" 12345678901234567890
In this example, we use the
big
string literal to create aBigInt
directly from a string.
Please note that the BigInt
function is used to create arbitrary precision integers, which allow for calculations with extremely large numbers that may exceed the range of regular Int
types.
See Also
BigFloat, BigInt, Dict, eltype, fieldtype, Float32, Float64, IntSet, isa, isalnum, isalpha, isascii, iseltype, isequal, isgraph, isimmutable, isinteractive, isleaftype, isnull, ispunct, isspace, issubtype, keytype, Nullable, NullException, promote_type, typeintersect, typejoin, typemax, typemin, typeof, Val, valtype,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.