<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>scs2mpf.c Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.2.15 --> <center> <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="annotated.html">Data Structures</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Data Fields</a> <a class="qindex" href="globals.html">Globals</a> </center> <hr><h1>scs2mpf.c</h1><div class="fragment"><pre>00001 <font class="comment">/*</font> 00002 <font class="comment"> * Author : Defour David</font> 00003 <font class="comment"> * Contact : David.Defour@ens-lyon.fr</font> 00004 <font class="comment"> *</font> 00005 <font class="comment"> * This program is free software; you can redistribute it and/or modify</font> 00006 <font class="comment"> * it under the terms of the GNU Lesser General Public License as published by</font> 00007 <font class="comment"> * the Free Software Foundation; either version 2 of the License, or </font> 00008 <font class="comment"> * (at your option) any later version.</font> 00009 <font class="comment"> * </font> 00010 <font class="comment"> * This program is distributed in the hope that it will be useful,</font> 00011 <font class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</font> 00012 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</font> 00013 <font class="comment"> * GNU General Public License for more details.</font> 00014 <font class="comment"> *</font> 00015 <font class="comment"> * You should have received a copy of the GNU Lesser General Public License</font> 00016 <font class="comment"> * along with this program; if not, write to the Free Software</font> 00017 <font class="comment"> * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. </font> 00018 <font class="comment"> */</font> 00019 00020 00021 <font class="preprocessor">#include "<a class="code" href="scs_8h.html">scs.h</a>"</font> 00022 <font class="preprocessor">#include "<a class="code" href="scs__private_8h.html">scs_private.h</a>"</font> 00023 00024 <font class="comment">/* Compile only if gmp is present */</font> 00025 00026 <font class="preprocessor">#ifdef HAVE_GMP_H</font> 00027 <font class="preprocessor"></font> 00028 <font class="comment">/*</font> 00029 <font class="comment"> * Convert a scs number into a MPF number (GMP)</font> 00030 <font class="comment"> */</font> 00031 <font class="keywordtype">void</font> scs_get_mpf(<a class="code" href="structscs.html">scs_ptr</a> x, mpf_t rop){ 00032 mpf_t mp1; 00033 <font class="keywordtype">long</font> <font class="keywordtype">int</font> expo; 00034 <font class="keywordtype">int</font> i; 00035 00036 mpf_set_ui(rop, 0); 00037 00038 <font class="comment">/* mantissa */</font> 00039 <font class="keywordflow">for</font> (i=0; i<SCS_NB_WORDS; i++){ 00040 mpf_mul_2exp(rop, rop, SCS_NB_BITS); 00041 mpf_add_ui(rop, rop, X_HW[i]); 00042 } 00043 00044 <font class="comment">/* sign */</font> 00045 <font class="keywordflow">if</font> (X_SGN == -1) mpf_neg(rop, rop); 00046 00047 <font class="comment">/* exception */</font> 00048 mpf_init_set_d(mp1, X_EXP); mpf_mul(rop, rop, mp1); 00049 00050 <font class="comment">/* exponent */</font> 00051 expo = (X_IND - SCS_NB_WORDS + 1) * SCS_NB_BITS; 00052 00053 <font class="keywordflow">if</font> (expo < 0) mpf_div_2exp(rop, rop, (<font class="keywordtype">unsigned</font> <font class="keywordtype">int</font>) -expo); 00054 <font class="keywordflow">else</font> mpf_mul_2exp(rop, rop, (<font class="keywordtype">unsigned</font> <font class="keywordtype">int</font>) expo); 00055 00056 mpf_clear(mp1); 00057 } 00058 <font class="preprocessor">#endif </font><font class="comment">/*HAVE_GMP_H*/</font> </pre></div><hr><address align="right"><small>Generated on Tue Jun 17 10:15:51 2003 for SCSLib by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.15 </small></address> </body> </html>