
Julio Moreno wrote:
In my case I have to work only with integers, maybe the proposal of working with long inside the operators could work. Since the beginning of the problema, it demands to work with integer. In the main method there is a single
Julio Moreno wrote:
My roots were calculated as follows (when determinant are positive are 2 roots because the + )
r1 = (int)((b) + Math.sqrt(d))/(2 * a);
r2 = (int)((b)  Math.sqrt(d))/(2 * a);
when I reformuled the equation, now without doing the int casting an error saying appears: Type mistmach cannot convert from double to int
That would mean thatStephan van Hulst wrote:. . . there are two terms that can fail due to overflow: (b * b) and (4 * a * c). . . . .
No, I searched the BigDecimal link with ctrl‑F‑root and got no hits. BigDecimal is intended for precise calculations; almost all rational numbers have irrational square roots, so their value cannot be calculated precisely, so BigDecimal doesn't seem to have a square root method. If you go to Math#sqrt, that method is not overloaded; it takes a double parameter. A double is intended for situations where absolute precision is not essential, and the rounding errors in calculating a square root can be tolerated.Stephan van Hulst wrote:Hmm, wow I could have sworn that you can take the root of at least a BigDecimal. . . .
A timing clock, fuse wire, high explosives and a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn KlassenKoop
https://coderanch.com/wiki/718759/books/BuildingWorldBackyardPaulWheaton
