big
big(x)
Convert a number to a maximum precision representation (typically BigInt
or BigFloat
). See BigFloat
for information about some pitfalls with floatingpoint numbers.
Examples

Convert an integer to a
BigInt
:julia> x = big(123456789) 123456789
The
big
function converts the integer123456789
to aBigInt
representation. 
Convert a floatingpoint number to a
BigFloat
:julia> y = big(3.14159) 3.14159
It converts the floatingpoint number
3.14159
to aBigFloat
. 
Ensure maximum precision for calculations:
julia> a = big(2.5) 2.500000000000000000000000000000000000000000000000000000000000000000000000000000 julia> b = big(0.1) 0.100000000000000005551115123125782702118158340454101562500000000000000000000000 julia> c = a + b 2.600000000000000177635683940025046467781066894531250000000000000000000000000000
This example demonstrates using
big
to achieve maximum precision when performing calculations involving floatingpoint numbers.
Common mistake example:
julia> z = big("Hello")
ERROR: MethodError: Cannot `convert` an object of type String to an object of type BigFloat
In this example, the big
function is used with a nonnumeric value. It's important to note that big
is used for converting numbers to their maximum precision representation and not for arbitrary nonnumeric types.
See Also
base, big, bytes2hex, cconvert, complex, convert, dec, hex, hex2bytes, hex2num, oct, oftype, parse, promote, signed, unsafe_convert, unsigned, widen,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.