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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<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.2EXAMPLES:sage: RDF(-1.5).sign()-1sage: RDF(0).sign()0sage: RDF(2.5).sign()1sign_mantissa_exponent()Return the sign, mantissa, <strong>and</strong> exponent of self.In <strong>Sage</strong> (as in MPFR), floating-point numbers of precision p are of the form sm2 e−p , where s ∈ {−1, 1},2 p−1 ≤ m < 2 p , <strong>and</strong> −2 30 +1 ≤ e ≤ 2 30 −1; plus the special values +0, -0, +infinity, -infinity,<strong>and</strong> NaN (which st<strong>and</strong>s for Not-a-Number).This function returns s, m, <strong>and</strong> e − p. For the special values:•+0 returns (1, 0, 0)•-0 returns (-1, 0, 0)•the return values for +infinity, -infinity, <strong>and</strong> NaN are not specified.EXAMPLES:sage: a = RDF(exp(1.0)); a2.71828182846sage: sign,mantissa,exponent = RDF(exp(1.0)).sign_mantissa_exponent()sage: sign,mantissa,exponent(1, 6121026514868073, -51)sage: sign*mantissa*(2**exponent) == aTrueThe mantissa is always a nonnegative number:sage: RDF(-1).sign_mantissa_exponent()(-1, 4503599627370496, -52)TESTS:sage: RDF(’+0’).sign_mantissa_exponent()(1, 0, 0)sage: RDF(’-0’).sign_mantissa_exponent()(-1, 0, 0)sin()Return the sine of self.EXAMPLES:sage: RDF(2).sin()0.909297426826sincos()Return a pair consisting of the sine <strong>and</strong> cosine of self.EXAMPLES:sage: t = RDF.pi()/6sage: t.sincos()(0.5, 0.866025403784)14 Chapter 1. Double <strong>Precision</strong> Real Numbers

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

Saved successfully!

Ooh no, something went wrong!