big

big(x)

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

Examples

  1. Convert an integer to a BigInt:

    julia> x = big(123456789)
    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)
    3.14159

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

  3. 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 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
Details

Checking you are not a robot: