This is Unofficial EPICS BASE Doxygen Site
epicsConvert.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * EPICS BASE is distributed subject to a Software License Agreement found
7 * in file LICENSE that is included with this distribution.
8 \*************************************************************************/
9 /*epicsConvert.c*/
10 
11 #include <float.h>
12 #include <limits.h>
13 
14 #include "epicsMath.h"
15 #include "epicsConvert.h"
16 #include "cantProceed.h"
17 
18 LIBCOM_API float epicsConvertDoubleToFloat(double value)
19 {
20  double abs;
21 
22  if (value == 0 || !finite(value))
23  return (float) value;
24 
25  abs = fabs(value);
26 
27  if (abs >= FLT_MAX)
28  return (value > 0) ? FLT_MAX : -FLT_MAX;
29 
30  if (abs <= FLT_MIN)
31  return (value > 0) ? FLT_MIN : -FLT_MIN;
32 
33  return (float) value;
34 }
Definition: link.h:174
LIBCOM_API float epicsConvertDoubleToFloat(double value)
Definition: epicsConvert.c:18
Routines for code that can&#39;t continue or return after an error.
#define finite(x)
Definition: epicsMath.h:16