[#JSCIENCE-76] Square root fails on some numbers

advertisement
[JSCIENCE-76] Square root fails on some numbers Created: 02/Jan/08
Status:
Project:
Component/s:
Affects
Version/s:
Fix Version/s:
Open
jscience
www
current
Type:
Reporter:
Resolution:
Labels:
Remaining
Estimate:
Time Spent:
Original
Estimate:
Environment:
Bug
octahedron80
Unresolved
None
Not Specified
Issuezilla Id:
76
Updated: 31/Jan/11
Version 6.0
Priority:
Assignee:
Votes:
Major
jscience-issues
0
Not Specified
Not Specified
Operating System: Windows XP
Platform: All
URL: http://tucomday.net
Description
According to "org.jscience.mathematics.number.LargeInteger", it has a method
called "sqrt()" for finding square root and flooring it. I use this method
commonly on my project. It works good at first. But later, I found that some
numbers result an error and make application terminate when I use the function.
I found:
LargeInteger.valueOf("8").sqrt()
is the cause of error. It returns "Java Result: 1" on err console instead of 2.
I wonder why it is so I try other else number. I found:
LargeInteger.valueOf("3").sqrt() ---> should be 1 but errs
LargeInteger.valueOf("15").sqrt() ---> should be 3 but errs
LargeInteger.valueOf("24").sqrt() ---> should be 4 but errs
LargeInteger.valueOf("35").sqrt() ---> should be 5 but errs
LargeInteger.valueOf("48").sqrt() ---> should be 6 but errs
etc.
also cause the same error. So I conclude that when I find the square root of
LargeInteger in form (n^2 - 1), it always ends up in the error. (3 = 2^2 - 1, 8
= 3^2 - 1, 15 = 4^2 - 1, etc.)
One more thing, I also found another case which causes different behavior.
LargeInteger.valueOf("0").sqrt() ---> should be 0 but errs
LargeInteger.valueOf("1").sqrt() ---> should be 1 but errs
They unnaturally return "java.lang.ArithmeticException: Division by zero".
Those are things I want to inform to the library developer. I use java 1.5, 1.6
on Windows XP. It causes both in IDE and command line. I need to use this
function correctly on my project. Thank you in advanced.
Octra Bond.
Comments
Comment by octahedron80 [ 02/Jan/08 ]
Oh, I almost forgot to tell. I use the latest library version 4.3.1. (earlier
4.3 too)
Generated at Tue Feb 09 17:47:22 UTC 2016 using JIRA 6.2.3#6260sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.
Download