Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Fixed
-
1.0-JSR-5
-
None
-
None
-
None
-
Mustang b82
Description
EXPECTED:
Main - <cn type="rational">2<sep/>1</cn>
Double - <cn type="rational">2<sep/>1</cn>
Result - <cn type="rational">2<sep/>1</cn>
ACTUAL:
Main - <cn type="rational">2<sep/>1</cn>
Double - <cn type="rational">null<sep/>null</cn>
Result - <cn type="rational">null<sep/>null</cn>
------------------------
import java.math.BigInteger
import java.math.BigDecimal
class Rational {
final BigInteger numerator
final BigInteger denominator
Rational(BigInteger numerator, BigInteger denominator) {
def gcd = numerator.gcd(denominator)
if (gcd > 0G)
this.numerator = numerator
this.denominator = denominator
println "Main - " + this
}
Rational(double number)
{ this(BigDecimal.valueOf(number)) println "Double - " + this }Rational(BigDecimal number)
{ this(number.unscaledValue(), BigInteger.TEN.pow(number.scale())) }String toString()
{ '<cn type="rational">' + numerator + '<sep/>' + denominator + '</cn>' }}
println "Result - " + new Rational(2)
Attachments
Issue Links
- is depended upon by
-
GROOVY-1381 new MOP implementation task
- Closed