-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add function bitsign
(inverse of signbit
)
#33341
Comments
Would this be generalized to complex powers as well? |
@StefanKarpinski Are you looking for |
I'm not looking for anything, just trying to reason about the function you've proposed. If the definition is that it computes julia> sign(1 + 1im)
0.7071067811865475 + 0.7071067811865475im |
@StefanKarpinski I see; going for a generic definition makes sense. Of course, the efficient implementation (much more efficient than actually calculating If you allow the exponent to be any real or complex number, then the implementation would be |
Right, that's part of why I was asking—the name seemed a bit too specific to the implementation. I think calling it |
It's also kind of amazing and unexpected that |
I just realize that we don't need |
No consensus that this is something desired (rejected from #35792) |
The mathematical expression
(-1)^n
appears in many equations. It would be convenient to have an efficient standard implementation in Julia. This is, in effect, the inverse of thesignbit
function.I propose the following implementation:
The text was updated successfully, but these errors were encountered: