88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.81 2002/09/04 20:31:27 momjian Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.82 2002/10/19 02:08:17 momjian Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -129,10 +129,10 @@ static void CheckFloat8Val(double val);
129129
130130
131131/*
132- check to see if a float4 val is outside of
133- the FLOAT4_MIN, FLOAT4_MAX bounds.
134-
135- raise an elog warning if it is
132+ * check to see if a float4 val is outside of
133+ * the FLOAT4_MIN, FLOAT4_MAX bounds.
134+ *
135+ * raise an elog warning if it is
136136*/
137137static void
138138CheckFloat4Val (double val )
@@ -153,11 +153,11 @@ CheckFloat4Val(double val)
153153}
154154
155155/*
156- check to see if a float8 val is outside of
157- the FLOAT8_MIN, FLOAT8_MAX bounds.
158-
159- raise an elogwarning if it is
160- */
156+ * check to see if a float8 val is outside of
157+ * the FLOAT8_MIN, FLOAT8_MAX bounds.
158+ *
159+ * raise an elogerror if it is
160+ */
161161static void
162162CheckFloat8Val (double val )
163163{
@@ -172,7 +172,6 @@ CheckFloat8Val(double val)
172172elog (ERROR ,"Bad float8 input format -- overflow" );
173173if (val != 0.0 && fabs (val )< FLOAT8_MIN )
174174elog (ERROR ,"Bad float8 input format -- underflow" );
175- return ;
176175#endif /* UNSAFE_FLOATS */
177176}
178177
@@ -1039,6 +1038,50 @@ dround(PG_FUNCTION_ARGS)
10391038PG_RETURN_FLOAT8 (result );
10401039}
10411040
1041+ /*
1042+ *dceil- returns the smallest integer greater than or
1043+ * equal to the specified float
1044+ */
1045+ Datum
1046+ dceil (PG_FUNCTION_ARGS )
1047+ {
1048+ float8 arg1 = PG_GETARG_FLOAT8 (0 );
1049+
1050+ PG_RETURN_FLOAT8 (ceil (arg1 ));
1051+ }
1052+
1053+ /*
1054+ *dfloor- returns the largest integer lesser than or
1055+ * equal to the specified float
1056+ */
1057+ Datum
1058+ dfloor (PG_FUNCTION_ARGS )
1059+ {
1060+ float8 arg1 = PG_GETARG_FLOAT8 (0 );
1061+
1062+ PG_RETURN_FLOAT8 (floor (arg1 ));
1063+ }
1064+
1065+ /*
1066+ *dsign- returns -1 if the argument is less than 0, 0
1067+ * if the argument is equal to 0, and 1 if the
1068+ * argument is greater than zero.
1069+ */
1070+ Datum
1071+ dsign (PG_FUNCTION_ARGS )
1072+ {
1073+ float8 arg1 = PG_GETARG_FLOAT8 (0 );
1074+ float8 result ;
1075+
1076+ if (arg1 > 0 )
1077+ result = 1.0 ;
1078+ else if (arg1 < 0 )
1079+ result = -1.0 ;
1080+ else
1081+ result = 0.0 ;
1082+
1083+ PG_RETURN_FLOAT8 (result );
1084+ }
10421085
10431086/*
10441087 *dtrunc- returns truncation-towards-zero of arg1,