11.07.2015 Views

Fixed and Arbitrary Precision Numerical Fields - Sage

Fixed and Arbitrary Precision Numerical Fields - Sage

Fixed and Arbitrary Precision Numerical Fields - Sage

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Sage</strong> Reference Manual: <strong>Fixed</strong> <strong>and</strong> <strong>Arbitrary</strong> <strong>Precision</strong> <strong>Numerical</strong> <strong>Fields</strong>, Release 6.2This leaves one case unspecified: in round to nearest mode, what happens if r is exactly halfway between the twonearest floating-point numbers? In that case, we round to the number with an even mantissa (the mantissa is thenumber m in the representation above).Consider the ordered set of floating-point numbers of precision p. (Here we identify +0 <strong>and</strong> -0, <strong>and</strong> ignore NaN.)We can give a bijection between these floating-point numbers <strong>and</strong> a segment of the integers, where 0 maps to 0 <strong>and</strong>adjacent floating-point numbers map to adjacent integers. We call the integer corresponding to a given floating-pointnumber the “floating-point rank” of the number. (This is not st<strong>and</strong>ard terminology; I just made it up.)EXAMPLES:A difficult conversion:sage: RR(sys.maxsize)9.22337203685478e18 # 64-bit2.14748364700000e9 # 32-bitTESTS:sage: -1e30-1.00000000000000e30Make sure we don’t have a new field for every new literal:sage: parent(2.0) is parent(2.0)Truesage: RealField(100, rnd=’RNDZ’) is RealField(100, rnd=’RNDD’)Falsesage: RealField(100, rnd=’RNDZ’) is RealField(100, rnd=’RNDZ’)Trueclass sage.rings.real_mpfr.QQtoRRBases: sage.categories.map.MapINPUT:There can be one or two arguments of this init method. If it is one argument, it must be a hom space. If it is twoarguments, it must be two parent structures that will be domain <strong>and</strong> codomain of the map-to-be-created.TESTS:sage: from sage.categories.map import MapUsing a hom space:sage: Map(Hom(QQ, ZZ, Rings()))Generic map:From: Rational FieldTo: Integer RingUsing domain <strong>and</strong> codomain:sage: Map(QQ[’x’], SymmetricGroup(6))Generic map:From: Univariate Polynomial Ring in x over Rational FieldTo: Symmetric group of order 6! as a permutation groupclass sage.rings.real_mpfr.RRtoRRBases: sage.categories.map.MapINPUT:26 Chapter 2. <strong>Arbitrary</strong> <strong>Precision</strong> Real Numbers

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!