Skip to content

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

@noeppi-noeppi

Description

@noeppi-noeppi

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.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions