Skip to content

round(Float64, 1.2) is documented to return 1.0, but throws. #50778

@LilithHafner

Description

@LilithHafner
help?> round(Float64, 1.2)
  round([T,] x, [r::RoundingMode])
  round(x, [r::RoundingMode]; digits::Integer=0, base = 10)
  round(x, [r::RoundingMode]; sigdigits::Integer, base = 10)

  Rounds the number x.

  Without keyword arguments, x is rounded to an integer value, returning a value 
  of type T, or of the same type of x if no T is provided. An InexactError will be 
  thrown if the value is not representable by T, similar to convert.

...

julia> round(Float64, 1.2)
ERROR: MethodError: no method matching round(::Type{Float64}, ::Float64)

Closest candidates are:
  round(::Type{Bool}, ::AbstractFloat)
   @ Base float.jl:391
  round(::Type{T}, ::AbstractFloat, ::RoundingMode) where T<:Integer
   @ Base floatfuncs.jl:122
  round(::Type{T}, ::AbstractFloat) where T<:Integer
   @ Base float.jl:385
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[13]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviormathsMathematical functions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions