On Monday, 10 April 2023 at 13:11:15 UTC-7 aw wrote:
[...]
print(RR(n1/n2))#passing as 8059,9042 as python ints
print(RR(8059/9042)) #passing 8059,9042 as sage ints
[...]
this bug is trivial to fix
when ints are passed to realfield, they should be automatically cast to
sage i
"2*1.1" is not a float literal. Note that RR(2.2) does what you want.
On Monday, April 10, 2023 at 1:42:21 PM UTC-7 aw wrote:
> sage version: 9.4
> operating system: fedora 35
>
> float literals passed to realfield can yield wrong answers
>
> example:
>
> RR=RealField(200)
>
> print(RR(1.1))
> pr
sage version: 9.4
operating system: fedora 35
float literals passed to realfield can yield wrong answers
example:
RR=RealField(200)
print(RR(1.1))
print(RR(11/10))
print()
print(RR(2*1.1))
print(RR(2*11/10))
output:
1.10
1.10
I don't think this is a bug that Sage can fix. When you execute
RR(8059/9042) in Python, it first evaluates 8059/9042 which produces a
float, then passes that to RR. There's no way for RR to know that you
initially input a ratio of ints.
David
On Mon, Apr 10, 2023 at 4:11 PM aw wrote:
> when p
when passing python ints to realfield, they don't get cast to sage integers
this can cause wrong answers
example:
RR=RealField(100)
set_random_seed(3)
n1=randint(1000,)#n1=8059
n2=randint(1000,)#n2=9042
print(n1,'/',n2,'=',sep='')
print(RR(n1/n2))#passing as 8059,