mpfr-conversion-functions.html 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <html lang="en">
  2. <head>
  3. <title>mpfr conversion functions - avram - a virtual machine code interpreter</title>
  4. <meta http-equiv="Content-Type" content="text/html">
  5. <meta name="description" content="avram - a virtual machine code interpreter">
  6. <meta name="generator" content="makeinfo 4.13">
  7. <link title="Top" rel="start" href="index.html#Top">
  8. <link rel="up" href="mpfr.html#mpfr" title="mpfr">
  9. <link rel="prev" href="mpfr-functions-with-miscellaneous-calling-conventions.html#mpfr-functions-with-miscellaneous-calling-conventions" title="mpfr functions with miscellaneous calling conventions">
  10. <link rel="next" href="mpfr-exceptions.html#mpfr-exceptions" title="mpfr exceptions">
  11. <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
  12. <meta http-equiv="Content-Style-Type" content="text/css">
  13. <style type="text/css"><!--
  14. pre.display { font-family:inherit }
  15. pre.format { font-family:inherit }
  16. pre.smalldisplay { font-family:inherit; font-size:smaller }
  17. pre.smallformat { font-family:inherit; font-size:smaller }
  18. pre.smallexample { font-size:smaller }
  19. pre.smalllisp { font-size:smaller }
  20. span.sc { font-variant:small-caps }
  21. span.roman { font-family:serif; font-weight:normal; }
  22. span.sansserif { font-family:sans-serif; font-weight:normal; }
  23. --></style>
  24. </head>
  25. <body>
  26. <div class="node">
  27. <a name="mpfr-conversion-functions"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="mpfr-exceptions.html#mpfr-exceptions">mpfr exceptions</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="mpfr-functions-with-miscellaneous-calling-conventions.html#mpfr-functions-with-miscellaneous-calling-conventions">mpfr functions with miscellaneous calling conventions</a>,
  31. Up:&nbsp;<a rel="up" accesskey="u" href="mpfr.html#mpfr">mpfr</a>
  32. <hr>
  33. </div>
  34. <h4 class="subsection">D.14.8 <code>mpfr</code> conversion functions</h4>
  35. <p>The functions described in this section convert between <code>mpfr</code>
  36. numbers and character strings, naturals, or standard IEEE floating
  37. point format (in their list representations). Where these functions
  38. have similar or equivalent counterparts in the <code>mpfr</code> library's
  39. native API, the names have been changed for mnemonic reasons.
  40. <dl>
  41. <dt><code>dbl2mp</code><dd>The input is a standard floating point number as in <a href="math.html#math">math</a>. The
  42. result is an <code>mpfr</code> number equal to the input with a
  43. fixed precision, currently set to 160 bits.
  44. <br><dt><code>mp2dbl</code><dd>The input is an <code>mpfr</code> number, and the output is the best
  45. possible approximation to it by a standard a double precision
  46. number.
  47. <br><dt><code>str2mp</code><dd>The input is a pair <code>(</code><var>prec</var><code>,</code><var>s</var><code>)</code>, where <var>prec</var> is a
  48. natural number specifying the precision, and <var>s</var> is a string
  49. expressing a floating point number in C format. The output is an
  50. <code>mpfr</code> number with the specified precision.
  51. <br><dt><code>mp2str</code><dd>The input is an <code>mpfr</code> number, and the output is a character
  52. string expressing the number in exponential decimal notation.
  53. Sufficiently many decimal digits are included in the string to express
  54. the full precision.
  55. <br><dt><code>nat2mp</code><dd>The input is a natural number represented as described in
  56. <a href="Representation-of-Numeric-and-Textual-Data.html#Representation-of-Numeric-and-Textual-Data">Representation of Numeric and Textual Data</a>,
  57. and the output is an <code>mpfr</code> number of sufficient precision to
  58. express the natural number exactly.
  59. </dl>
  60. <p>The <code>mp2str</code> function enhances the native <code>mpfr_get_str</code>
  61. function by properly formatting the output string rather than only
  62. listing the digits of the mantissa.
  63. <p>The <code>nat2mp</code> function does not rely on the <code>mpfr</code> native
  64. integer conversion functions, so natural numbers with any number of
  65. bits up to <code>MP_PREC_MAX</code> can be used losslessly. There is
  66. currently no conversion in the other direction.
  67. </body></html>