Julia: Should `sinpi` and `cospi` return integers for integer input?

Created on 9 May 2020  路  5Comments  路  Source: JuliaLang/julia

I think returning floating point numbers for integer inputs doesn't make much sense, since the results are always integer. sinpi is especially weird, since it returns differently signed zeros for positive and negative integer inputs. In #33341, it was also discussed that cospi is actually the inverse of signbit, in which case integer output would also make a lot more sense. Is there a particular reason for the current behavior? Changing the output type might be too breaking for a minor release, but it would at least make sense to reconsider for 2.0.

Most helpful comment

I will once it passes its own tests. PkgEval is pretty expensive.

All 5 comments

I fully agree that sinpi and cospi should map integers to integers. If there wouldn't be "minor breaking" changes in julia (e.g. #34200, #33864, https://github.com/JuliaLang/julia/pull/33533#issuecomment-541210103 and likely more), I'd say this is something for 2.0. Though, those issues are arguably of greater range, so I'm leaning towards 2.0.

Changing the type of a function like this would be potentially eligible for a minor release, but we'd have to run PkgEval to see if there's any negative fallout in the ecosystem. If there aren't any problems, then we could potentially change it before 2.0.

@StefanKarpinski would you mind to run PkgEval on #35823, please? Thanks!

I will once it passes its own tests. PkgEval is pretty expensive.

Yes, sorry, I made an embarrassing sign error before. 馃檲 The doctest failure now should be unrelated though.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sbromberger picture sbromberger  路  3Comments

i-apellaniz picture i-apellaniz  路  3Comments

tkoolen picture tkoolen  路  3Comments

m-j-w picture m-j-w  路  3Comments

musm picture musm  路  3Comments