Skip to content

float(::Dual) disagrees with Base #492

@mcabbott

Description

@mcabbott

I was surprised by this:

using ForwardDiff: Dual, value
x1 = Dual.(1:4, 2:5, 3:6)
value.(float.(x1)) # Vector{Float16}
float.(value.(x1)) # Vector{Float64}

While one could argue that Julia should have different promotion / widening rules, it seems hard to argue that Dual types should disagree. This example caught me when trying to wrap a function which only accepts Float32 & Float64, as seems fairly common for C libraries.

Edit -- xref #419, about AbstractFloat.

And #362, about Int -> Float16. Example from here is ForwardDiff.derivative(first∘sincos, 1) isa Float16

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions