1/* mpfr_sub_d -- subtract a machine double precision float from 2 a multiple precision floating-point number 3 4Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. 5Contributed by the AriC and Caramel projects, INRIA. 6 7This file is part of the GNU MPFR Library. 8 9The GNU MPFR Library is free software; you can redistribute it and/or modify 10it under the terms of the GNU Lesser General Public License as published by 11the Free Software Foundation; either version 3 of the License, or (at your 12option) any later version. 13 14The GNU MPFR Library is distributed in the hope that it will be useful, but 15WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 17License for more details. 18 19You should have received a copy of the GNU Lesser General Public License 20along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see 21http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., 2251 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ 23 24#include "mpfr-impl.h" 25 26int 27mpfr_sub_d (mpfr_ptr a, mpfr_srcptr b, double c, mpfr_rnd_t rnd_mode) 28{ 29 int inexact; 30 mpfr_t d; 31 MPFR_SAVE_EXPO_DECL (expo); 32 33 MPFR_LOG_FUNC 34 (("b[%Pu]=%.*Rg c=%.20g rnd=%d", 35 mpfr_get_prec (b), mpfr_log_prec, b, c, rnd_mode), 36 ("a[%Pu]=%.*Rg", mpfr_get_prec (a), mpfr_log_prec, a)); 37 38 MPFR_SAVE_EXPO_MARK (expo); 39 40 mpfr_init2 (d, IEEE_DBL_MANT_DIG); 41 inexact = mpfr_set_d (d, c, rnd_mode); 42 MPFR_ASSERTN (inexact == 0); 43 44 mpfr_clear_flags (); 45 inexact = mpfr_sub (a, b, d, rnd_mode); 46 MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags); 47 48 mpfr_clear(d); 49 MPFR_SAVE_EXPO_FREE (expo); 50 return mpfr_check_range (a, inexact, rnd_mode); 51} 52