1 | initial version |
Hi,
It depends. You have the choice or using the Cython variable as follows
from sage.rings.real_mpfr cimport RealNumber
from sage.rings.real_mpfr import RR
cdef RealNumber my_number = RR(4)
...
Or you can use pure C as follows
cdef mpfr_t value
...
It might help to have a look at how the real number are implemented in Sage in the files
$SAGE_ROOT/devel/sage-main/sage/rings/real_mpfr.pyx
$SAGE_ROOT/devel/sage-main/sage/rings/real_mpfr.pxd
2 | No.2 Revision |
Hi,
It depends. You have the choice or of using the a Cython variable as follows
from sage.rings.real_mpfr cimport RealNumber
from sage.rings.real_mpfr import RR
cdef RealNumber my_number = RR(4)
RR(5.634)
...
Or you can use pure C as follows
cdef mpfr_t value
mpfr_init2(value, 53)
mpfr_set_flt(value, 5.364, MPFR_RNDN)
...
Anyway, in the latter case, it is not possible to write value = 5
because there is no cast from int to mpfr_t (those are C variables)!
It might help to have a look at how the real number are implemented in Sage in the files
$SAGE_ROOT/devel/sage-main/sage/rings/real_mpfr.pyx
$SAGE_ROOT/devel/sage-main/sage/rings/real_mpfr.pxd