-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mean
of fixed-point numbers is a Float64
#306
Comments
mean
of fixed-point numbersmean
of fixed-point numbers is a Float64
At least that is the behavior @timholy intended. This is consistent with the default behavior of integer types. julia> typeof(mean([0x80, 0x80]))
Float64 Also, while |
Note that it is not a good idea to use |
@timholy Can I ask the rationale for this behavior?
julia> N0f8(.5) + N0f8(.5) |> typeof
N0f8 (alias for Normed{UInt8, 8})
julia> reduce(+, [N0f8(.5), N0f8(.5)]) |> typeof
N0f8 (alias for Normed{UInt8, 8})
julia> sum([N0f8(.5), N0f8(.5)]) |> typeof
Float64
julia> N0f8(1)/2 |> typeof
Float32 |
As implied above, julia> 0x80 + 0x80 |> typeof
UInt8
julia> reduce(+, [0x80, 0x80]) |> typeof
UInt8
julia> sum([0x80, 0x80]) |> typeof
UInt64
julia> 0xff/2 |> typeof
Float64 Of course, since fixed-point numbers are different from both integers and floating-point numbers, this package can and shall design its own rules. And, there is already a design. |
I am planning to change the design once Statistics.jl provides a richer public API. |
Is this the intended behavior? I expected it would round to the nearest fixed-point number.
The text was updated successfully, but these errors were encountered: