Convert a number to a maximum precision representation (typically BigInt or BigFloat). See BigFloat for information about some pitfalls with floating-point numbers.


  1. Convert an integer to a BigInt:

    julia> x = big(123456789)

    The big function converts the integer 123456789 to a BigInt representation.

  2. Convert a floating-point number to a BigFloat:

    julia> y = big(3.14159)

    It converts the floating-point number 3.14159 to a BigFloat.

  3. Ensure maximum precision for calculations:

    julia> a = big(2.5)
    julia> b = big(0.1)
    julia> c = a + b

    This example demonstrates using big to achieve maximum precision when performing calculations involving floating-point 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 non-numeric value. It's important to note that big is used for converting numbers to their maximum precision representation and not for arbitrary non-numeric 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.

*Required Field

Checking you are not a robot: