[prev in list] [next in list] [prev in thread] [next in thread] 

List:       groovy-scm
Subject:    [groovy-scm] [jira] Closed: (GROOVY-1315) class field confused / corrupted
From:       "Jochen Theodorou (JIRA)" <jira () codehaus ! org>
Date:       2006-11-28 12:38:41
Message-ID: 79326414.1164717521162.JavaMail.haus-jira () codehaus01 ! managed ! contegix ! com
[Download RAW message or body]

     [ http://jira.codehaus.org/browse/GROOVY-1315?page=all ]

Jochen Theodorou closed GROOVY-1315.
------------------------------------

      Assignee: Jochen Theodorou  (was: John Wilson)
    Resolution: Fixed

fixed

> class field confused / corrupted
> --------------------------------
> 
> Key: GROOVY-1315
> URL: http://jira.codehaus.org/browse/GROOVY-1315
> Project: groovy
> Issue Type: Bug
> Affects Versions: 1.0-JSR-5
> Environment: Mustang b82
> Reporter: Alex Lam S.L.
> Assigned To: Jochen Theodorou
> Priority: Blocker
> 
> 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) {
> numerator = numerator.divide(gcd)
> denominator = denominator.divide(gcd)
> }
> 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)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: \
                http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

<hr/>
<p>
To unsubscribe from this list please visit:
</p>
<p>
    <a href="http://xircles.codehaus.org/manage_email">http://xircles.codehaus.org/manage_email</a>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic