Home | History | Annotate | Line # | Download | only in src
      1 /* mpfr_print_rnd_mode -- convert a given rounding mode to a string
      2 
      3 Copyright 1999, 2001-2004, 2006-2023 Free Software Foundation, Inc.
      4 Contributed by the AriC and Caramba projects, INRIA.
      5 
      6 This file is part of the GNU MPFR Library.
      7 
      8 The GNU MPFR Library is free software; you can redistribute it and/or modify
      9 it under the terms of the GNU Lesser General Public License as published by
     10 the Free Software Foundation; either version 3 of the License, or (at your
     11 option) any later version.
     12 
     13 The GNU MPFR Library is distributed in the hope that it will be useful, but
     14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
     15 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
     16 License for more details.
     17 
     18 You should have received a copy of the GNU Lesser General Public License
     19 along with the GNU MPFR Library; see the file COPYING.LESSER.  If not, see
     20 https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
     21 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
     22 
     23 #include "mpfr-impl.h"
     24 
     25 /* WARNING! When adding a new rounding mode, do not forget to update the
     26    description of this mpfr_print_rnd_mode function in the manual. */
     27 
     28 const char *
     29 mpfr_print_rnd_mode (mpfr_rnd_t rnd_mode)
     30 {
     31   /* If we forget to update this function after a new rounding mode
     32      is added, this will be detected by the following assertion. */
     33   MPFR_STAT_STATIC_ASSERT (MPFR_RND_MAX == MPFR_RNDF + 1);
     34   switch (rnd_mode)
     35     {
     36     case MPFR_RNDD:
     37       return "MPFR_RNDD";
     38     case MPFR_RNDU:
     39       return "MPFR_RNDU";
     40     case MPFR_RNDN:
     41       return "MPFR_RNDN";
     42     case MPFR_RNDZ:
     43       return "MPFR_RNDZ";
     44     case MPFR_RNDA:
     45       return "MPFR_RNDA";
     46     case MPFR_RNDF:
     47       return "MPFR_RNDF";
     48     default:
     49       return (const char*) 0;
     50     }
     51 }
     52