Skip to content
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

BigComplexMath.sqrt fails on non-positive real numbers #66

Open
noeppi-noeppi opened this issue Jun 4, 2023 · 2 comments
Open

BigComplexMath.sqrt fails on non-positive real numbers #66

noeppi-noeppi opened this issue Jun 4, 2023 · 2 comments
Assignees
Labels

Comments

@noeppi-noeppi
Copy link

When BigComplexMath.sqrt is invoked with an argument that has a negative or zero real part and a zero imaginary part, it throws an ArithmeticException:

BigComplexMath.sqrt(BigComplex.ONE.negate(), MathContext.DECIMAL64)
Exception in thread "main" java.lang.ArithmeticException: Division undefined
	at java.base/java.math.BigDecimal.divide(BigDecimal.java:1831)
	at ch.obermuhlner.math.big.BigComplex.divide(BigComplex.java:287)
	at ch.obermuhlner.math.big.BigComplexMath.sqrt(BigComplexMath.java:289)

Expected behaviour:

BigComplexMath.sqrt should not throw an ArithmeticException but compute the result (in the above case 0 + 1i) instead.

noeppi-noeppi added a commit to noeppi-noeppi/TuxCalculator that referenced this issue Jun 4, 2023
…ts for real numbers between 0 and 1. Contains a workaround for eobermuhlner/big-math#66
noeppi-noeppi added a commit to noeppi-noeppi/TuxCalculator that referenced this issue Jun 5, 2023
…ts for real numbers between 0 and 1. Contains a workaround for eobermuhlner/big-math#66
@eobermuhlner eobermuhlner self-assigned this Jun 6, 2023
@eobermuhlner
Copy link
Owner

The bug is confirmed and I am working on a fix.

Thanks for reporting it.

@nadment
Copy link

nadment commented Aug 31, 2023

This should also solve a problem with the ACOS function.

BigDecimalMath.acosh(BigDecimal.ZERO, MathContext.DECIMAL128); >> Illegal sqrt(x) for x < 0: x = -1

runforlife added a commit to runforlife/bigdecimal-math that referenced this issue Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants