Closed r9y9 closed 9 years ago
On the latest master, converting an (unsigned) negative value to a signed value such as convert(Int16, a::UInt64)seems to throw an InexactError.
convert(Int16, a::UInt64)
julia> convert(Int16, uint(2^15) | ~unsigned(0) << 16) -32768
julia> convert(Int16, uint(2^15) | ~unsigned(0) << 16) ERROR: InexactError() in convert at int.jl:155
so we need to have explicit unsigned conversion using signed instead of converting it directly.
signed
julia> convert(Int16, signed(uint(2^15) | ~unsigned(0) << 16)) -32768
I hope this fixes https://github.com/dancasimiro/WAV.jl/issues/21.
Coverage increased (+0.08%) to 63.83% when pulling e4b7d9d7a2ad8da02bc7efa5dd0204d93f663c14 on r9y9:fix-sign-extend-nagative-values into 00dfe9a37c86ccdf57cfd1b2e5ac70a2a6cae4eb on dancasimiro:master.
I decided to go with the version that always calls "signed." See 9b7a6972cc5c701392ea6af687bcc20918ae400e
Looks good to me. Thanks
On the latest master, converting an (unsigned) negative value to a signed value such as
convert(Int16, a::UInt64)
seems to throw an InexactError.so we need to have explicit unsigned conversion using
signed
instead of converting it directly.I hope this fixes https://github.com/dancasimiro/WAV.jl/issues/21.