Java polynomial root search

I am new to Java and have created a Polynomial Root Finder with a GUI. One of the problems I'm currently running into and don't quite understand is the value that comes from perfect squares like (x + 5) ^ 2.

int y = 0;
    for(int x = -100000; x < 100000; x++) {
        int math = (A * (x * x)) + (B * x) + C;
        if(math == 0) {
            Zeros[y] = x;
            y++;
        }
    }

      

Now for some reason Zeros [0] returns -65541 and I'm not sure why. Now if I make x bounds from -10000 to 10000 the problem goes away and shows the correct roots. I'm just asking why -65541 gets as root.

Here is a photo of my problem.

Picture

+3
java


source to share


No one has answered this question yet

See similar questions:

2
Why does Java int increment end up with a negative number?

or similar:

6170
Is Java "pass-by-reference" or "pass-by-value"?
3799
How do I read / convert an InputStream to a string in Java?
3324
How to generate random integers in a specific range in Java?
3073
How to efficiently loop over each entry in a Java map?
3044
Making a memory leak with Java
2956
What is the difference between public, secure, batch and private in Java?
2936
When to use LinkedList over ArrayList in Java?
2853
How can I convert String to int in Java?
2248
Is a finally block always executable in Java?
1367
Fastest way to determine if an integer square root is an integer



All Articles
Loading...
X
Show
Funny
Dev
Pics