3 ms·
>BigDecimal has an add() method Using it for formulas makes for wonderful code. Try y = (5x^3 - 3x^2 + 7x + 1)/(3x^2 - 7x) See how readable that is usin
by romwell 8y ago
>BigDecimal has an add() method
Using it for formulas makes for wonderful code.
Try
y = (5x^3 - 3x^2 + 7x + 1)/(3x^2 - 7x)
See how readable that is using methods like .add()
Side note: the notation we have is not that old; but as soon as people actually started working with polynomials, they invented notation that makes it sane.
That's to say, Java's .add() is so 1400's.
- sorokod 8y agoThere is no argument from me that a + b is more readable than a.add(b). Java founding fathers (Gosling?) decided against operator overloading sighting the mess it allowed to created in other languages. The mathematical notations for spelling out polynomials has been optimized over some time - Java being a general purpose programming language has other fish to fry. There are languages that allow for a cleaner way to express mathematical statements, this is valid Julia: julia> p(x) = (5x^3 - 3x^2 + 7x + 1)/(3x^2 - 7x) p (generic function with 1 method) julia> p(1 + 2im) 2.4 + 0.2im