..  BigFloat(x)

Create an arbitrary precision floating point number. ``x`` may be
an ``Integer``, a ``Float64`` or a ``BigInt``. The
usual mathematical operators are defined for this type, and results
are promoted to a ``BigFloat``.

Note that because decimal literals are converted to floating point numbers
when parsed, ``BigFloat(2.1)`` may not yield what you expect. You may instead
prefer to initialize constants from strings via :func:`parse`, or using the
``big`` string literal.

.. doctest::

   julia> BigFloat(2.1)

   julia> big"2.1"


The BigFloat(x) function in Julia is used to create an arbitrary precision floating-point number. The input x can be a NaN, an Integer, a Float64, or a BigInt. Mathematical operators are defined for this type, and results are promoted to a BigFloat.

Here are some examples of how to use the BigFloat function:

  1. Create a BigFloat from an Integer:

    julia> BigFloat(10)
  2. Create a BigFloat from a Float64:

    julia> BigFloat(3.14)
  3. Create a BigFloat from a BigInt:
    julia> BigFloat(big(123456789))

It's important to note that when using decimal literals, they are converted to floating-point numbers when parsed. This can result in some loss of precision. To ensure precise initialization, you can use the parse function or the big string literal.

Here is an example using parse to initialize from a string:

julia> parse(BigFloat, "2.1")

And here is an example using the big string literal:

julia> big"2.1"

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.

*Required Field

Checking you are not a robot: