On 8/27/07, Justin Walker <[EMAIL PROTECTED]> wrote:
> Hi, all,
>
> I do this, and get integers, but the types are rational:
>
> sage: b1=0
> sage: b2=2
> sage: s=(b1+b2)/2
> sage: n=(b1-b2)/2
> sage: s
> 1
> sage: n
> -1

That s and n are rational is correct, since "/ is a constructor
for elements of the fraction field".   If you want integers
you might do a floor div or explicit coercion:
     s = (b1+b2)//2
or
     s = ZZ((b1+b2)/2)

> Then I do this:
>
> sage: xgcd(s,n)
> ---------------------------------------------------------------------------
> <type 'exceptions.AttributeError'>        Traceback (most recent call last)
>
> /SandBox/Justin/sb/Sage/Code/<ipython console> in <module>()
>
> /SandBox/Justin/sb/sage-2.8/local/lib/python2.5/site-packages/sage/rings/arith.py
>  in xgcd(a, b)
>    1122     if not isinstance(a, RingElement):
>    1123         a = integer_ring.ZZ(a)
> -> 1124     return a.xgcd(b)
>    1125
>    1126 XGCD = xgcd
>
> <type 'exceptions.AttributeError'>: 'sage.rings.rational.Rational' object has 
> no attribute 'xgcd'
>
> Is this expected?  It seems, somehow, wrong :-}

It's a bug.  The fix is in the attached patch.

William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Attachment: 5891.patch
Description: Binary data

Reply via email to