Back to index

glibc  2.9
q_cmpe.c
Go to the documentation of this file.
00001 /* Software floating-point emulation.
00002    Compare a and b, return float condition code.
00003    Signal exception (unless masked) if unordered.
00004    Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
00005    This file is part of the GNU C Library.
00006    Contributed by Richard Henderson (rth@cygnus.com) and
00007                 Jakub Jelinek (jj@ultra.linux.cz).
00008 
00009    The GNU C Library is free software; you can redistribute it and/or
00010    modify it under the terms of the GNU Lesser General Public
00011    License as published by the Free Software Foundation; either
00012    version 2.1 of the License, or (at your option) any later version.
00013 
00014    The GNU C Library is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017    Lesser General Public License for more details.
00018 
00019    You should have received a copy of the GNU Lesser General Public
00020    License along with the GNU C Library; if not, write to the Free
00021    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00022    02111-1307 USA.  */
00023 
00024 #include "soft-fp.h"
00025 #include "quad.h"
00026 
00027 int _q_cmpe(const long double a, const long double b)
00028 {
00029   FP_DECL_EX;
00030   FP_DECL_Q(A); FP_DECL_Q(B);
00031   int r;
00032 
00033   FP_UNPACK_RAW_Q(A, a);
00034   FP_UNPACK_RAW_Q(B, b);
00035   FP_CMP_Q(r, B, A, 3);
00036   if (r == -1) r = 2;
00037   if (r == 3)
00038     FP_SET_EXCEPTION(FP_EX_INVALID);
00039   FP_HANDLE_EXCEPTIONS;
00040 
00041   return r;
00042 }