PostgreSQL Source Code  git master
float.h File Reference
#include <math.h>
Include dependency graph for float.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define M_PI   3.14159265358979323846
 
#define RADIANS_PER_DEGREE   0.0174532925199432957692
 

Functions

void float_overflow_error (void) pg_attribute_noreturn()
 
void float_underflow_error (void) pg_attribute_noreturn()
 
void float_zero_divide_error (void) pg_attribute_noreturn()
 
int is_infinite (float8 val)
 
float8 float8in_internal (char *num, char **endptr_p, const char *type_name, const char *orig_string)
 
float8 float8in_internal_opt_error (char *num, char **endptr_p, const char *type_name, const char *orig_string, bool *have_error)
 
char * float8out_internal (float8 num)
 
int float4_cmp_internal (float4 a, float4 b)
 
int float8_cmp_internal (float8 a, float8 b)
 
static float4 get_float4_infinity (void)
 
static float8 get_float8_infinity (void)
 
static float4 get_float4_nan (void)
 
static float8 get_float8_nan (void)
 
static float4 float4_pl (const float4 val1, const float4 val2)
 
static float8 float8_pl (const float8 val1, const float8 val2)
 
static float4 float4_mi (const float4 val1, const float4 val2)
 
static float8 float8_mi (const float8 val1, const float8 val2)
 
static float4 float4_mul (const float4 val1, const float4 val2)
 
static float8 float8_mul (const float8 val1, const float8 val2)
 
static float4 float4_div (const float4 val1, const float4 val2)
 
static float8 float8_div (const float8 val1, const float8 val2)
 
static bool float4_eq (const float4 val1, const float4 val2)
 
static bool float8_eq (const float8 val1, const float8 val2)
 
static bool float4_ne (const float4 val1, const float4 val2)
 
static bool float8_ne (const float8 val1, const float8 val2)
 
static bool float4_lt (const float4 val1, const float4 val2)
 
static bool float8_lt (const float8 val1, const float8 val2)
 
static bool float4_le (const float4 val1, const float4 val2)
 
static bool float8_le (const float8 val1, const float8 val2)
 
static bool float4_gt (const float4 val1, const float4 val2)
 
static bool float8_gt (const float8 val1, const float8 val2)
 
static bool float4_ge (const float4 val1, const float4 val2)
 
static bool float8_ge (const float8 val1, const float8 val2)
 
static float4 float4_min (const float4 val1, const float4 val2)
 
static float8 float8_min (const float8 val1, const float8 val2)
 
static float4 float4_max (const float4 val1, const float4 val2)
 
static float8 float8_max (const float8 val1, const float8 val2)
 

Variables

PGDLLIMPORT int extra_float_digits
 

Macro Definition Documentation

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 22 of file float.h.

◆ RADIANS_PER_DEGREE

#define RADIANS_PER_DEGREE   0.0174532925199432957692

Definition at line 26 of file float.h.

Referenced by cosd_0_to_60(), degrees(), init_degree_constants(), radians(), and sind_0_to_30().

Function Documentation

◆ float4_cmp_internal()

int float4_cmp_internal ( float4  a,
float4  b 
)

Definition at line 820 of file float.c.

References float4_gt(), and float4_lt().

Referenced by btfloat4cmp(), and btfloat4fastcmp().

821 {
822  if (float4_gt(a, b))
823  return 1;
824  if (float4_lt(a, b))
825  return -1;
826  return 0;
827 }
static bool float4_gt(const float4 val1, const float4 val2)
Definition: float.h:309
static bool float4_lt(const float4 val1, const float4 val2)
Definition: float.h:285

◆ float4_div()

static float4 float4_div ( const float4  val1,
const float4  val2 
)
inlinestatic

Definition at line 221 of file float.h.

References float_overflow_error(), float_underflow_error(), float_zero_divide_error(), and unlikely.

Referenced by float4div(), and g_box_consider_split().

222 {
223  float4 result;
224 
225  if (unlikely(val2 == 0.0f) && !isnan(val1))
227  result = val1 / val2;
228  if (unlikely(isinf(result)) && !isinf(val1) && !isinf(val2))
230  if (unlikely(result == 0.0f) && val1 != 0.0f)
232 
233  return result;
234 }
void float_zero_divide_error(void) pg_attribute_noreturn()
Definition: float.c:100
float float4
Definition: c.h:497
void float_overflow_error(void) pg_attribute_noreturn()
Definition: float.c:84
void float_underflow_error(void) pg_attribute_noreturn()
Definition: float.c:92
#define unlikely(x)
Definition: c.h:206

◆ float4_eq()

static bool float4_eq ( const float4  val1,
const float4  val2 
)
inlinestatic

Definition at line 261 of file float.h.

Referenced by float4eq().

262 {
263  return isnan(val1) ? isnan(val2) : !isnan(val2) && val1 == val2;
264 }

◆ float4_ge()

static bool float4_ge ( const float4  val1,
const float4  val2 
)
inlinestatic

Definition at line 321 of file float.h.

Referenced by float4ge().

322 {
323  return isnan(val1) || (!isnan(val2) && val1 >= val2);
324 }

◆ float4_gt()

static bool float4_gt ( const float4  val1,
const float4  val2 
)
inlinestatic

Definition at line 309 of file float.h.

Referenced by float4_cmp_internal(), float4_max(), float4gt(), and float4larger().

310 {
311  return !isnan(val2) && (isnan(val1) || val1 > val2);
312 }

◆ float4_le()

static bool float4_le ( const float4  val1,
const float4  val2 
)
inlinestatic

Definition at line 297 of file float.h.

Referenced by float4le().

298 {
299  return isnan(val2) || (!isnan(val1) && val1 <= val2);
300 }

◆ float4_lt()

static bool float4_lt ( const float4  val1,
const float4  val2 
)
inlinestatic

Definition at line 285 of file float.h.

Referenced by float4_cmp_internal(), float4_min(), float4lt(), and float4smaller().

286 {
287  return !isnan(val1) && (isnan(val2) || val1 < val2);
288 }

◆ float4_max()

static float4 float4_max ( const float4  val1,
const float4  val2 
)
inlinestatic

Definition at line 345 of file float.h.

References float4_gt().

346 {
347  return float4_gt(val1, val2) ? val1 : val2;
348 }
static bool float4_gt(const float4 val1, const float4 val2)
Definition: float.h:309

◆ float4_mi()

static float4 float4_mi ( const float4  val1,
const float4  val2 
)
inlinestatic

Definition at line 169 of file float.h.

References float_overflow_error(), and unlikely.

Referenced by float4mi().

170 {
171  float4 result;
172 
173  result = val1 - val2;
174  if (unlikely(isinf(result)) && !isinf(val1) && !isinf(val2))
176 
177  return result;
178 }
float float4
Definition: c.h:497
void float_overflow_error(void) pg_attribute_noreturn()
Definition: float.c:84
#define unlikely(x)
Definition: c.h:206

◆ float4_min()

static float4 float4_min ( const float4  val1,
const float4  val2 
)
inlinestatic

Definition at line 333 of file float.h.

References float4_lt().

334 {
335  return float4_lt(val1, val2) ? val1 : val2;
336 }
static bool float4_lt(const float4 val1, const float4 val2)
Definition: float.h:285

◆ float4_mul()

static float4 float4_mul ( const float4  val1,
const float4  val2 
)
inlinestatic

Definition at line 193 of file float.h.

References float_overflow_error(), float_underflow_error(), and unlikely.

Referenced by float4mul().

194 {
195  float4 result;
196 
197  result = val1 * val2;
198  if (unlikely(isinf(result)) && !isinf(val1) && !isinf(val2))
200  if (unlikely(result == 0.0f) && val1 != 0.0f && val2 != 0.0f)
202 
203  return result;
204 }
float float4
Definition: c.h:497
void float_overflow_error(void) pg_attribute_noreturn()
Definition: float.c:84
void float_underflow_error(void) pg_attribute_noreturn()
Definition: float.c:92
#define unlikely(x)
Definition: c.h:206

◆ float4_ne()

static bool float4_ne ( const float4  val1,
const float4  val2 
)
inlinestatic

Definition at line 273 of file float.h.

Referenced by float4ne().

274 {
275  return isnan(val1) ? !isnan(val2) : isnan(val2) || val1 != val2;
276 }

◆ float4_pl()

static float4 float4_pl ( const float4  val1,
const float4  val2 
)
inlinestatic

Definition at line 145 of file float.h.

References float_overflow_error(), and unlikely.

Referenced by float4pl().

146 {
147  float4 result;
148 
149  result = val1 + val2;
150  if (unlikely(isinf(result)) && !isinf(val1) && !isinf(val2))
152 
153  return result;
154 }
float float4
Definition: c.h:497
void float_overflow_error(void) pg_attribute_noreturn()
Definition: float.c:84
#define unlikely(x)
Definition: c.h:206

◆ float8_cmp_internal()

int float8_cmp_internal ( float8  a,
float8  b 
)

Definition at line 914 of file float.c.

References float8_gt(), and float8_lt().

Referenced by btfloat48cmp(), btfloat84cmp(), btfloat8cmp(), btfloat8fastcmp(), common_entry_cmp(), interval_cmp_lower(), interval_cmp_upper(), and pairingheap_GISTSearchItem_cmp().

915 {
916  if (float8_gt(a, b))
917  return 1;
918  if (float8_lt(a, b))
919  return -1;
920  return 0;
921 }
static bool float8_lt(const float8 val1, const float8 val2)
Definition: float.h:291
static bool float8_gt(const float8 val1, const float8 val2)
Definition: float.h:315

◆ float8_div()

static float8 float8_div ( const float8  val1,
const float8  val2 
)
inlinestatic

Definition at line 237 of file float.h.

References float_overflow_error(), float_underflow_error(), float_zero_divide_error(), and unlikely.

Referenced by box_circle(), box_cn(), circle_box(), circle_div_pt(), circle_poly(), degrees(), float48div(), float84div(), float8div(), g_box_consider_split(), line_distance(), line_eq(), line_interpt_line(), line_invsl(), line_perp(), line_sl(), lseg_center(), lseg_inside_poly(), path_area(), point_div_point(), point_invsl(), point_sl(), and poly_to_circle().

238 {
239  float8 result;
240 
241  if (unlikely(val2 == 0.0) && !isnan(val1))
243  result = val1 / val2;
244  if (unlikely(isinf(result)) && !isinf(val1) && !isinf(val2))
246  if (unlikely(result == 0.0) && val1 != 0.0)
248 
249  return result;
250 }
void float_zero_divide_error(void) pg_attribute_noreturn()
Definition: float.c:100
double float8
Definition: c.h:498
void float_overflow_error(void) pg_attribute_noreturn()
Definition: float.c:84
void float_underflow_error(void) pg_attribute_noreturn()
Definition: float.c:92
#define unlikely(x)
Definition: c.h:206

◆ float8_eq()

static bool float8_eq ( const float8  val1,
const float8  val2 
)
inlinestatic

Definition at line 267 of file float.h.

Referenced by float48eq(), float84eq(), float8eq(), gist_box_picksplit(), gist_box_same(), line_eq(), and point_eq_point().

268 {
269  return isnan(val1) ? isnan(val2) : !isnan(val2) && val1 == val2;
270 }

◆ float8_ge()

static bool float8_ge ( const float8  val1,
const float8  val2 
)
inlinestatic

Definition at line 327 of file float.h.

Referenced by float48ge(), float84ge(), float8ge(), and gist_box_picksplit().

328 {
329  return isnan(val1) || (!isnan(val2) && val1 >= val2);
330 }

◆ float8_gt()

static bool float8_gt ( const float8  val1,
const float8  val2 
)
inlinestatic

Definition at line 315 of file float.h.

Referenced by adjustBox(), box_construct(), float48gt(), float84gt(), float8_cmp_internal(), float8_max(), float8gt(), float8larger(), gist_box_picksplit(), and make_bound_box().

316 {
317  return !isnan(val2) && (isnan(val1) || val1 > val2);
318 }

◆ float8_le()

static bool float8_le ( const float8  val1,
const float8  val2 
)
inlinestatic

Definition at line 303 of file float.h.

Referenced by float48le(), float84le(), float8le(), gist_box_picksplit(), and size_box().

304 {
305  return isnan(val2) || (!isnan(val1) && val1 <= val2);
306 }

◆ float8_lt()

static bool float8_lt ( const float8  val1,
const float8  val2 
)
inlinestatic

◆ float8_max()

static float8 float8_max ( const float8  val1,
const float8  val2 
)
inlinestatic

Definition at line 351 of file float.h.

References float8_gt().

Referenced by box_interpt_lseg(), box_intersect(), boxes_bound_box(), path_inter(), and rt_box_union().

352 {
353  return float8_gt(val1, val2) ? val1 : val2;
354 }
static bool float8_gt(const float8 val1, const float8 val2)
Definition: float.h:315

◆ float8_mi()

static float8 float8_mi ( const float8  val1,
const float8  val2 
)
inlinestatic

◆ float8_min()

static float8 float8_min ( const float8  val1,
const float8  val2 
)
inlinestatic

Definition at line 339 of file float.h.

References float8_lt().

Referenced by box_interpt_lseg(), box_intersect(), boxes_bound_box(), path_inter(), and rt_box_union().

340 {
341  return float8_lt(val1, val2) ? val1 : val2;
342 }
static bool float8_lt(const float8 val1, const float8 val2)
Definition: float.h:291

◆ float8_mul()

static float8 float8_mul ( const float8  val1,
const float8  val2 
)
inlinestatic

Definition at line 207 of file float.h.

References float_overflow_error(), float_underflow_error(), and unlikely.

Referenced by box_ar(), circle_ar(), circle_diameter(), circle_mul_pt(), circle_poly(), float48mul(), float84mul(), float8mul(), line_construct(), line_contain_point(), line_distance(), line_eq(), line_interpt_line(), line_perp(), lseg_crossing(), path_area(), point_div_point(), point_mul_point(), radians(), and size_box().

208 {
209  float8 result;
210 
211  result = val1 * val2;
212  if (unlikely(isinf(result)) && !isinf(val1) && !isinf(val2))
214  if (unlikely(result == 0.0) && val1 != 0.0 && val2 != 0.0)
216 
217  return result;
218 }
double float8
Definition: c.h:498
void float_overflow_error(void) pg_attribute_noreturn()
Definition: float.c:84
void float_underflow_error(void) pg_attribute_noreturn()
Definition: float.c:92
#define unlikely(x)
Definition: c.h:206

◆ float8_ne()

static bool float8_ne ( const float8  val1,
const float8  val2 
)
inlinestatic

Definition at line 279 of file float.h.

Referenced by float48ne(), float84ne(), and float8ne().

280 {
281  return isnan(val1) ? !isnan(val2) : isnan(val2) || val1 != val2;
282 }

◆ float8_pl()

static float8 float8_pl ( const float8  val1,
const float8  val2 
)
inlinestatic

Definition at line 157 of file float.h.

References float_overflow_error(), and unlikely.

Referenced by box_circle(), box_cn(), circle_above(), circle_below(), circle_box(), circle_distance(), circle_left(), circle_overbelow(), circle_overlap(), circle_overleft(), circle_poly(), circle_right(), float48pl(), float84pl(), float8_combine(), float8_regr_combine(), float8pl(), gist_circle_compress(), gist_circle_consistent(), line_contain_point(), line_interpt_line(), lseg_center(), lseg_inside_poly(), on_ppath(), path_area(), path_length(), point_add_point(), point_div_point(), point_mul_point(), and poly_to_circle().

158 {
159  float8 result;
160 
161  result = val1 + val2;
162  if (unlikely(isinf(result)) && !isinf(val1) && !isinf(val2))
164 
165  return result;
166 }
double float8
Definition: c.h:498
void float_overflow_error(void) pg_attribute_noreturn()
Definition: float.c:84
#define unlikely(x)
Definition: c.h:206

◆ float8in_internal()

float8 float8in_internal ( char *  num,
char **  endptr_p,
const char *  type_name,
const char *  orig_string 
)

Definition at line 513 of file float.c.

References float8in_internal_opt_error().

Referenced by float8in(), pair_decode(), and single_decode().

515 {
516  return float8in_internal_opt_error(num, endptr_p, type_name,
517  orig_string, NULL);
518 }
double float8in_internal_opt_error(char *num, char **endptr_p, const char *type_name, const char *orig_string, bool *have_error)
Definition: float.c:379

◆ float8in_internal_opt_error()

float8 float8in_internal_opt_error ( char *  num,
char **  endptr_p,
const char *  type_name,
const char *  orig_string,
bool have_error 
)

Definition at line 379 of file float.c.

References ereport, errcode(), errmsg(), ERROR, get_float8_infinity(), get_float8_nan(), pg_strncasecmp(), pstrdup(), RETURN_ERROR, and val.

Referenced by executeItemOptUnwrapTarget(), and float8in_internal().

382 {
383  double val;
384  char *endptr;
385 
386  if (have_error)
387  *have_error = false;
388 
389  /* skip leading whitespace */
390  while (*num != '\0' && isspace((unsigned char) *num))
391  num++;
392 
393  /*
394  * Check for an empty-string input to begin with, to avoid the vagaries of
395  * strtod() on different platforms.
396  */
397  if (*num == '\0')
399  (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
400  errmsg("invalid input syntax for type %s: \"%s\"",
401  type_name, orig_string))),
402  have_error);
403 
404  errno = 0;
405  val = strtod(num, &endptr);
406 
407  /* did we not see anything that looks like a double? */
408  if (endptr == num || errno != 0)
409  {
410  int save_errno = errno;
411 
412  /*
413  * C99 requires that strtod() accept NaN, [+-]Infinity, and [+-]Inf,
414  * but not all platforms support all of these (and some accept them
415  * but set ERANGE anyway...) Therefore, we check for these inputs
416  * ourselves if strtod() fails.
417  *
418  * Note: C99 also requires hexadecimal input as well as some extended
419  * forms of NaN, but we consider these forms unportable and don't try
420  * to support them. You can use 'em if your strtod() takes 'em.
421  */
422  if (pg_strncasecmp(num, "NaN", 3) == 0)
423  {
424  val = get_float8_nan();
425  endptr = num + 3;
426  }
427  else if (pg_strncasecmp(num, "Infinity", 8) == 0)
428  {
429  val = get_float8_infinity();
430  endptr = num + 8;
431  }
432  else if (pg_strncasecmp(num, "+Infinity", 9) == 0)
433  {
434  val = get_float8_infinity();
435  endptr = num + 9;
436  }
437  else if (pg_strncasecmp(num, "-Infinity", 9) == 0)
438  {
439  val = -get_float8_infinity();
440  endptr = num + 9;
441  }
442  else if (pg_strncasecmp(num, "inf", 3) == 0)
443  {
444  val = get_float8_infinity();
445  endptr = num + 3;
446  }
447  else if (pg_strncasecmp(num, "+inf", 4) == 0)
448  {
449  val = get_float8_infinity();
450  endptr = num + 4;
451  }
452  else if (pg_strncasecmp(num, "-inf", 4) == 0)
453  {
454  val = -get_float8_infinity();
455  endptr = num + 4;
456  }
457  else if (save_errno == ERANGE)
458  {
459  /*
460  * Some platforms return ERANGE for denormalized numbers (those
461  * that are not zero, but are too close to zero to have full
462  * precision). We'd prefer not to throw error for that, so try to
463  * detect whether it's a "real" out-of-range condition by checking
464  * to see if the result is zero or huge.
465  *
466  * On error, we intentionally complain about double precision not
467  * the given type name, and we print only the part of the string
468  * that is the current number.
469  */
470  if (val == 0.0 || val >= HUGE_VAL || val <= -HUGE_VAL)
471  {
472  char *errnumber = pstrdup(num);
473 
474  errnumber[endptr - num] = '\0';
476  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
477  errmsg("\"%s\" is out of range for type double precision",
478  errnumber))),
479  have_error);
480  }
481  }
482  else
484  (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
485  errmsg("invalid input syntax for type "
486  "%s: \"%s\"",
487  type_name, orig_string))),
488  have_error);
489  }
490 
491  /* skip trailing whitespace */
492  while (*endptr != '\0' && isspace((unsigned char) *endptr))
493  endptr++;
494 
495  /* report stopping point if wanted, else complain if not end of string */
496  if (endptr_p)
497  *endptr_p = endptr;
498  else if (*endptr != '\0')
500  (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
501  errmsg("invalid input syntax for type "
502  "%s: \"%s\"",
503  type_name, orig_string))),
504  have_error);
505 
506  return val;
507 }
static float8 get_float8_infinity(void)
Definition: float.h:93
char * pstrdup(const char *in)
Definition: mcxt.c:1187
int errcode(int sqlerrcode)
Definition: elog.c:610
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
Definition: pgstrcasecmp.c:69
#define ERROR
Definition: elog.h:43
static float8 get_float8_nan(void)
Definition: float.h:122
#define ereport(elevel,...)
Definition: elog.h:144
#define RETURN_ERROR(throw_error, have_error)
Definition: float.c:347
int errmsg(const char *fmt,...)
Definition: elog.c:824
long val
Definition: informix.c:664

◆ float8out_internal()

char* float8out_internal ( float8  num)

Definition at line 541 of file float.c.

References ascii(), double_to_shortest_decimal_buf(), extra_float_digits, palloc(), and pg_strfromd().

Referenced by cube_out(), float8out(), line_out(), pair_encode(), and single_encode().

542 {
543  char *ascii = (char *) palloc(32);
544  int ndig = DBL_DIG + extra_float_digits;
545 
546  if (extra_float_digits > 0)
547  {
548  double_to_shortest_decimal_buf(num, ascii);
549  return ascii;
550  }
551 
552  (void) pg_strfromd(ascii, 32, ndig, num);
553  return ascii;
554 }
Datum ascii(PG_FUNCTION_ARGS)
int pg_strfromd(char *str, size_t count, int precision, double value)
Definition: snprintf.c:1263
int extra_float_digits
Definition: float.c:42
int double_to_shortest_decimal_buf(double f, char *result)
Definition: d2s.c:1053
void * palloc(Size size)
Definition: mcxt.c:950

◆ float_overflow_error()

void float_overflow_error ( void  )

Definition at line 84 of file float.c.

References ereport, errcode(), errmsg(), ERROR, and pg_noinline.

Referenced by dacos(), dacosd(), dasin(), dasind(), datan(), datan2(), datan2d(), datand(), dcbrt(), dcos(), dcosd(), dexp(), dlog1(), dlog10(), dpow(), dsin(), dsind(), dsqrt(), dtanh(), dtof(), float4_accum(), float4_div(), float4_mi(), float4_mul(), float4_pl(), float8_accum(), float8_combine(), float8_div(), float8_mi(), float8_mul(), float8_pl(), float8_regr_accum(), float8_regr_combine(), and pg_hypot().

85 {
86  ereport(ERROR,
87  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
88  errmsg("value out of range: overflow")));
89 }
int errcode(int sqlerrcode)
Definition: elog.c:610
#define ERROR
Definition: elog.h:43
#define ereport(elevel,...)
Definition: elog.h:144
int errmsg(const char *fmt,...)
Definition: elog.c:824

◆ float_underflow_error()

void float_underflow_error ( void  )

Definition at line 92 of file float.c.

References ereport, errcode(), errmsg(), ERROR, and pg_noinline.

Referenced by dcbrt(), dcosh(), dexp(), dlog1(), dlog10(), dpow(), dsqrt(), dtof(), float4_div(), float4_mul(), float8_div(), float8_mul(), and pg_hypot().

93 {
94  ereport(ERROR,
95  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
96  errmsg("value out of range: underflow")));
97 }
int errcode(int sqlerrcode)
Definition: elog.c:610
#define ERROR
Definition: elog.h:43
#define ereport(elevel,...)
Definition: elog.h:144
int errmsg(const char *fmt,...)
Definition: elog.c:824

◆ float_zero_divide_error()

void float_zero_divide_error ( void  )

Definition at line 100 of file float.c.

References ereport, errcode(), errmsg(), and ERROR.

Referenced by float4_div(), and float8_div().

101 {
102  ereport(ERROR,
103  (errcode(ERRCODE_DIVISION_BY_ZERO),
104  errmsg("division by zero")));
105 }
int errcode(int sqlerrcode)
Definition: elog.c:610
#define ERROR
Definition: elog.h:43
#define ereport(elevel,...)
Definition: elog.h:144
int errmsg(const char *fmt,...)
Definition: elog.c:824

◆ get_float4_infinity()

static float4 get_float4_infinity ( void  )
inlinestatic

Definition at line 73 of file float.h.

Referenced by float4in(), gistpenalty(), leftmostvalue_float4(), numeric_float4(), and range_gist_penalty().

74 {
75 #ifdef INFINITY
76  /* C99 standard way */
77  return (float4) INFINITY;
78 #else
79 #ifdef _MSC_VER
80 #pragma warning(default:4756)
81 #endif
82 
83  /*
84  * On some platforms, HUGE_VAL is an infinity, elsewhere it's just the
85  * largest normal float8. We assume forcing an overflow will get us a
86  * true infinity.
87  */
88  return (float4) (HUGE_VAL * HUGE_VAL);
89 #endif
90 }
float float4
Definition: c.h:497

◆ get_float4_nan()

static float4 get_float4_nan ( void  )
inlinestatic

Definition at line 110 of file float.h.

Referenced by float4in(), and numeric_float4().

111 {
112 #ifdef NAN
113  /* C99 standard way */
114  return (float4) NAN;
115 #else
116  /* Assume we can get a NAN via zero divide */
117  return (float4) (0.0 / 0.0);
118 #endif
119 }
float float4
Definition: c.h:497

◆ get_float8_infinity()

static float8 get_float8_infinity ( void  )
inlinestatic

Definition at line 93 of file float.h.

Referenced by compute_range_stats(), datanh(), dcosh(), dsinh(), float8in_internal_opt_error(), gbt_ts_dist(), get_distance(), gistindex_keytest(), initRectBox(), leftmostvalue_float8(), NonFiniteTimestampTzPart(), numeric_float8(), pg_hypot(), size_box(), spg_kd_inner_consistent(), spg_quad_inner_consistent(), and spgbeginscan().

94 {
95 #ifdef INFINITY
96  /* C99 standard way */
97  return (float8) INFINITY;
98 #else
99 
100  /*
101  * On some platforms, HUGE_VAL is an infinity, elsewhere it's just the
102  * largest normal float8. We assume forcing an overflow will get us a
103  * true infinity.
104  */
105  return (float8) (HUGE_VAL * HUGE_VAL);
106 #endif
107 }
double float8
Definition: c.h:498

◆ get_float8_nan()

static float8 get_float8_nan ( void  )
inlinestatic

Definition at line 122 of file float.h.

Referenced by dacos(), dacosd(), dasin(), dasind(), datan(), datan2(), datan2d(), datand(), dcos(), dcosd(), dcot(), dcotd(), dpow(), dsin(), dsind(), dtan(), dtand(), float4_accum(), float8_accum(), float8_regr_accum(), float8in_internal_opt_error(), line_closept_point(), numeric_float8(), numeric_float8_no_overflow(), pg_hypot(), and point_box_distance().

123 {
124  /* (float8) NAN doesn't work on some NetBSD/MIPS releases */
125 #if defined(NAN) && !(defined(__NetBSD__) && defined(__mips__))
126  /* C99 standard way */
127  return (float8) NAN;
128 #else
129  /* Assume we can get a NaN via zero divide */
130  return (float8) (0.0 / 0.0);
131 #endif
132 }
double float8
Definition: c.h:498

◆ is_infinite()

int is_infinite ( float8  val)

Definition at line 116 of file float.c.

117 {
118  int inf = isinf(val);
119 
120  if (inf == 0)
121  return 0;
122  else if (val > 0)
123  return 1;
124  else
125  return -1;
126 }
long val
Definition: informix.c:664

Variable Documentation

◆ extra_float_digits

PGDLLIMPORT int extra_float_digits

Definition at line 42 of file float.c.

Referenced by float4out(), float8out_internal(), and set_transmission_modes().