PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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

pg_noreturn void float_overflow_error (void)
 
pg_noreturn void float_underflow_error (void)
 
pg_noreturn void float_zero_divide_error (void)
 
float8 float_overflow_error_ext (struct Node *escontext)
 
float8 float_underflow_error_ext (struct Node *escontext)
 
float8 float_zero_divide_error_ext (struct Node *escontext)
 
int is_infinite (float8 val)
 
float8 float8in_internal (char *num, char **endptr_p, const char *type_name, const char *orig_string, struct Node *escontext)
 
float4 float4in_internal (char *num, char **endptr_p, const char *type_name, const char *orig_string, struct Node *escontext)
 
charfloat8out_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_safe (const float8 val1, const float8 val2, struct Node *escontext)
 
static float8 float8_pl (const float8 val1, const float8 val2)
 
static float4 float4_mi (const float4 val1, const float4 val2)
 
static float8 float8_mi_safe (const float8 val1, const float8 val2, struct Node *escontext)
 
static float8 float8_mi (const float8 val1, const float8 val2)
 
static float4 float4_mul (const float4 val1, const float4 val2)
 
static float8 float8_mul_safe (const float8 val1, const float8 val2, struct Node *escontext)
 
static float8 float8_mul (const float8 val1, const float8 val2)
 
static float4 float4_div (const float4 val1, const float4 val2)
 
static float8 float8_div_safe (const float8 val1, const float8 val2, struct Node *escontext)
 
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.

Function Documentation

◆ float4_cmp_internal()

int float4_cmp_internal ( float4  a,
float4  b 
)
extern

Definition at line 857 of file float.c.

858{
859 if (float4_gt(a, b))
860 return 1;
861 if (float4_lt(a, b))
862 return -1;
863 return 0;
864}
static bool float4_lt(const float4 val1, const float4 val2)
Definition float.h:268
static bool float4_gt(const float4 val1, const float4 val2)
Definition float.h:292
int b
Definition isn.c:74
int a
Definition isn.c:73

References a, b, float4_gt(), and float4_lt().

Referenced by btfloat4cmp(), btfloat4fastcmp(), and gbt_float4_ssup_cmp().

◆ float4_div()

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

Definition at line 198 of file float.h.

199{
201
202 if (unlikely(val2 == 0.0f) && !isnan(val1))
204 result = val1 / val2;
205 if (unlikely(isinf(result)) && !isinf(val1))
207 if (unlikely(result == 0.0f) && val1 != 0.0f && !isinf(val2))
209
210 return result;
211}
#define unlikely(x)
Definition c.h:438
float float4
Definition c.h:713
uint32 result
pg_noreturn void float_overflow_error(void)
Definition float.c:103
pg_noreturn void float_underflow_error(void)
Definition float.c:111
pg_noreturn void float_zero_divide_error(void)
Definition float.c:119
static int fb(int x)

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

Referenced by float4div(), and g_box_consider_split().

◆ float4_eq()

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

Definition at line 244 of file float.h.

245{
246 return isnan(val1) ? isnan(val2) : !isnan(val2) && val1 == val2;
247}

References fb().

Referenced by float4eq().

◆ float4_ge()

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

Definition at line 304 of file float.h.

305{
306 return isnan(val1) || (!isnan(val2) && val1 >= val2);
307}

References fb().

Referenced by float4ge().

◆ float4_gt()

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

Definition at line 292 of file float.h.

293{
294 return !isnan(val2) && (isnan(val1) || val1 > val2);
295}

References fb().

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

◆ float4_le()

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

Definition at line 280 of file float.h.

281{
282 return isnan(val2) || (!isnan(val1) && val1 <= val2);
283}

References fb().

Referenced by float4le().

◆ float4_lt()

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

Definition at line 268 of file float.h.

269{
270 return !isnan(val1) && (isnan(val2) || val1 < val2);
271}

References fb().

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

◆ float4_max()

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

Definition at line 328 of file float.h.

329{
330 return float4_gt(val1, val2) ? val1 : val2;
331}

References fb(), and float4_gt().

◆ float4_mi()

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

Definition at line 134 of file float.h.

135{
137
138 result = val1 - val2;
139 if (unlikely(isinf(result)) && !isinf(val1) && !isinf(val2))
141
142 return result;
143}

References fb(), float_overflow_error(), result, and unlikely.

Referenced by float4mi().

◆ float4_min()

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

Definition at line 316 of file float.h.

317{
318 return float4_lt(val1, val2) ? val1 : val2;
319}

References fb(), and float4_lt().

◆ float4_mul()

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

Definition at line 164 of file float.h.

165{
167
168 result = val1 * val2;
169 if (unlikely(isinf(result)) && !isinf(val1) && !isinf(val2))
171 if (unlikely(result == 0.0f) && val1 != 0.0f && val2 != 0.0f)
173
174 return result;
175}

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

Referenced by float4mul().

◆ float4_ne()

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

Definition at line 256 of file float.h.

257{
258 return isnan(val1) ? !isnan(val2) : isnan(val2) || val1 != val2;
259}

References fb().

Referenced by float4ne().

◆ float4_pl()

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

Definition at line 104 of file float.h.

105{
107
108 result = val1 + val2;
109 if (unlikely(isinf(result)) && !isinf(val1) && !isinf(val2))
111
112 return result;
113}

References fb(), float_overflow_error(), result, and unlikely.

Referenced by float4pl().

◆ float4in_internal()

float4 float4in_internal ( char num,
char **  endptr_p,
const char type_name,
const char orig_string,
struct Node escontext 
)
extern

Definition at line 224 of file float.c.

227{
228 float val;
229 char *endptr;
230
231 /*
232 * endptr points to the first character _after_ the sequence we recognized
233 * as a valid floating point number. orig_string points to the original
234 * input string.
235 */
236
237 /* skip leading whitespace */
238 while (*num != '\0' && isspace((unsigned char) *num))
239 num++;
240
241 /*
242 * Check for an empty-string input to begin with, to avoid the vagaries of
243 * strtod() on different platforms.
244 */
245 if (*num == '\0')
246 ereturn(escontext, 0,
248 errmsg("invalid input syntax for type %s: \"%s\"",
249 type_name, orig_string)));
250
251 errno = 0;
252 val = strtof(num, &endptr);
253
254 /* did we not see anything that looks like a double? */
255 if (endptr == num || errno != 0)
256 {
257 int save_errno = errno;
258
259 /*
260 * C99 requires that strtof() accept NaN, [+-]Infinity, and [+-]Inf,
261 * but not all platforms support all of these (and some accept them
262 * but set ERANGE anyway...) Therefore, we check for these inputs
263 * ourselves if strtof() fails.
264 *
265 * Note: C99 also requires hexadecimal input as well as some extended
266 * forms of NaN, but we consider these forms unportable and don't try
267 * to support them. You can use 'em if your strtof() takes 'em.
268 */
269 if (pg_strncasecmp(num, "NaN", 3) == 0)
270 {
272 endptr = num + 3;
273 }
274 else if (pg_strncasecmp(num, "Infinity", 8) == 0)
275 {
277 endptr = num + 8;
278 }
279 else if (pg_strncasecmp(num, "+Infinity", 9) == 0)
280 {
282 endptr = num + 9;
283 }
284 else if (pg_strncasecmp(num, "-Infinity", 9) == 0)
285 {
287 endptr = num + 9;
288 }
289 else if (pg_strncasecmp(num, "inf", 3) == 0)
290 {
292 endptr = num + 3;
293 }
294 else if (pg_strncasecmp(num, "+inf", 4) == 0)
295 {
297 endptr = num + 4;
298 }
299 else if (pg_strncasecmp(num, "-inf", 4) == 0)
300 {
302 endptr = num + 4;
303 }
304 else if (save_errno == ERANGE)
305 {
306 /*
307 * Some platforms return ERANGE for denormalized numbers (those
308 * that are not zero, but are too close to zero to have full
309 * precision). We'd prefer not to throw error for that, so try to
310 * detect whether it's a "real" out-of-range condition by checking
311 * to see if the result is zero or huge.
312 */
313 if (val == 0.0 ||
314#if !defined(HUGE_VALF)
315 isinf(val)
316#else
317 (val >= HUGE_VALF || val <= -HUGE_VALF)
318#endif
319 )
320 {
321 /* see comments in float8in_internal for rationale */
322 char *errnumber = pstrdup(num);
323
324 errnumber[endptr - num] = '\0';
325
326 ereturn(escontext, 0,
328 errmsg("\"%s\" is out of range for type real",
329 errnumber)));
330 }
331 }
332 else
333 ereturn(escontext, 0,
335 errmsg("invalid input syntax for type %s: \"%s\"",
336 type_name, orig_string)));
337 }
338
339 /* skip trailing whitespace */
340 while (*endptr != '\0' && isspace((unsigned char) *endptr))
341 endptr++;
342
343 /* report stopping point if wanted, else complain if not end of string */
344 if (endptr_p)
345 *endptr_p = endptr;
346 else if (*endptr != '\0')
347 ereturn(escontext, 0,
349 errmsg("invalid input syntax for type %s: \"%s\"",
350 type_name, orig_string)));
351
352 return val;
353}
int errcode(int sqlerrcode)
Definition elog.c:874
#define ereturn(context, dummy_value,...)
Definition elog.h:280
static float4 get_float4_infinity(void)
Definition float.h:61
static float4 get_float4_nan(void)
Definition float.h:80
long val
Definition informix.c:689
char * pstrdup(const char *in)
Definition mcxt.c:1781
static char * errmsg
int pg_strncasecmp(const char *s1, const char *s2, size_t n)

References ereturn, errcode(), errmsg, fb(), get_float4_infinity(), get_float4_nan(), pg_strncasecmp(), pstrdup(), and val.

Referenced by float4in().

◆ float8_cmp_internal()

int float8_cmp_internal ( float8  a,
float8  b 
)
extern

Definition at line 951 of file float.c.

952{
953 if (float8_gt(a, b))
954 return 1;
955 if (float8_lt(a, b))
956 return -1;
957 return 0;
958}
static bool float8_lt(const float8 val1, const float8 val2)
Definition float.h:274
static bool float8_gt(const float8 val1, const float8 val2)
Definition float.h:298

References a, b, float8_gt(), and float8_lt().

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

◆ float8_div()

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

Definition at line 230 of file float.h.

231{
232 return float8_div_safe(val1, val2, NULL);
233}
static float8 float8_div_safe(const float8 val1, const float8 val2, struct Node *escontext)
Definition float.h:214

References fb(), and float8_div_safe().

Referenced by cash_div_float8(), circle_div_pt(), circle_poly_internal(), degrees(), float48div(), float84div(), float8div(), g_box_consider_split(), line_distance(), line_eq(), line_interpt_line(), line_invsl(), line_perp(), line_sl(), lseg_inside_poly(), path_area(), point_div_point(), point_invsl(), and point_sl().

◆ float8_div_safe()

static float8 float8_div_safe ( const float8  val1,
const float8  val2,
struct Node escontext 
)
inlinestatic

Definition at line 214 of file float.h.

215{
217
218 if (unlikely(val2 == 0.0) && !isnan(val1))
219 return float_zero_divide_error_ext(escontext);
220 result = val1 / val2;
221 if (unlikely(isinf(result)) && !isinf(val1))
222 return float_overflow_error_ext(escontext);
223 if (unlikely(result == 0.0) && val1 != 0.0 && !isinf(val2))
224 return float_underflow_error_ext(escontext);
225
226 return result;
227}
double float8
Definition c.h:714
float8 float_underflow_error_ext(struct Node *escontext)
Definition float.c:135
float8 float_overflow_error_ext(struct Node *escontext)
Definition float.c:127
float8 float_zero_divide_error_ext(struct Node *escontext)
Definition float.c:143

References fb(), float_overflow_error_ext(), float_underflow_error_ext(), float_zero_divide_error_ext(), result, and unlikely.

Referenced by box_circle(), box_cn(), circle_box(), float8_div(), lseg_center(), and poly_to_circle().

◆ float8_eq()

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

Definition at line 250 of file float.h.

251{
252 return isnan(val1) ? isnan(val2) : !isnan(val2) && val1 == val2;
253}

References fb().

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

◆ float8_ge()

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

Definition at line 310 of file float.h.

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

References fb().

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

◆ float8_gt()

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

Definition at line 298 of file float.h.

299{
300 return !isnan(val2) && (isnan(val1) || val1 > val2);
301}

References fb().

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

◆ float8_le()

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

Definition at line 286 of file float.h.

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

References fb().

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

◆ float8_lt()

◆ float8_max()

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

Definition at line 334 of file float.h.

335{
336 return float8_gt(val1, val2) ? val1 : val2;
337}

References fb(), and float8_gt().

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

◆ float8_mi()

◆ float8_mi_safe()

static float8 float8_mi_safe ( const float8  val1,
const float8  val2,
struct Node escontext 
)
inlinestatic

Definition at line 146 of file float.h.

147{
149
150 result = val1 - val2;
151 if (unlikely(isinf(result)) && !isinf(val1) && !isinf(val2))
152 return float_overflow_error_ext(escontext);
153
154 return result;
155}

References fb(), float_overflow_error_ext(), result, and unlikely.

Referenced by circle_box(), circle_poly_internal(), float8_mi(), and point_dt().

◆ float8_min()

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

Definition at line 322 of file float.h.

323{
324 return float8_lt(val1, val2) ? val1 : val2;
325}

References fb(), and float8_lt().

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

◆ float8_mul()

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

◆ float8_mul_safe()

static float8 float8_mul_safe ( const float8  val1,
const float8  val2,
struct Node escontext 
)
inlinestatic

Definition at line 178 of file float.h.

179{
181
182 result = val1 * val2;
183 if (unlikely(isinf(result)) && !isinf(val1) && !isinf(val2))
184 return float_overflow_error_ext(escontext);
185 if (unlikely(result == 0.0) && val1 != 0.0 && val2 != 0.0)
186 return float_underflow_error_ext(escontext);
187
188 return result;
189}

References fb(), float_overflow_error_ext(), float_underflow_error_ext(), result, and unlikely.

Referenced by circle_poly_internal(), and float8_mul().

◆ float8_ne()

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

Definition at line 262 of file float.h.

263{
264 return isnan(val1) ? !isnan(val2) : isnan(val2) || val1 != val2;
265}

References fb().

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

◆ float8_pl()

◆ float8_pl_safe()

static float8 float8_pl_safe ( const float8  val1,
const float8  val2,
struct Node escontext 
)
inlinestatic

Definition at line 116 of file float.h.

117{
119
120 result = val1 + val2;
121 if (unlikely(isinf(result)) && !isinf(val1) && !isinf(val2))
122 return float_overflow_error_ext(escontext);
123
124 return result;
125}

References fb(), float_overflow_error_ext(), result, and unlikely.

Referenced by box_circle(), box_cn(), circle_box(), circle_poly_internal(), float8_pl(), lseg_center(), point_add_point(), and poly_to_circle().

◆ float8in_internal()

float8 float8in_internal ( char num,
char **  endptr_p,
const char type_name,
const char orig_string,
struct Node escontext 
)
extern

Definition at line 436 of file float.c.

439{
440 double val;
441 char *endptr;
442
443 /* skip leading whitespace */
444 while (*num != '\0' && isspace((unsigned char) *num))
445 num++;
446
447 /*
448 * Check for an empty-string input to begin with, to avoid the vagaries of
449 * strtod() on different platforms.
450 */
451 if (*num == '\0')
452 ereturn(escontext, 0,
454 errmsg("invalid input syntax for type %s: \"%s\"",
455 type_name, orig_string)));
456
457 errno = 0;
458 val = strtod(num, &endptr);
459
460 /* did we not see anything that looks like a double? */
461 if (endptr == num || errno != 0)
462 {
463 int save_errno = errno;
464
465 /*
466 * C99 requires that strtod() accept NaN, [+-]Infinity, and [+-]Inf,
467 * but not all platforms support all of these (and some accept them
468 * but set ERANGE anyway...) Therefore, we check for these inputs
469 * ourselves if strtod() fails.
470 *
471 * Note: C99 also requires hexadecimal input as well as some extended
472 * forms of NaN, but we consider these forms unportable and don't try
473 * to support them. You can use 'em if your strtod() takes 'em.
474 */
475 if (pg_strncasecmp(num, "NaN", 3) == 0)
476 {
478 endptr = num + 3;
479 }
480 else if (pg_strncasecmp(num, "Infinity", 8) == 0)
481 {
483 endptr = num + 8;
484 }
485 else if (pg_strncasecmp(num, "+Infinity", 9) == 0)
486 {
488 endptr = num + 9;
489 }
490 else if (pg_strncasecmp(num, "-Infinity", 9) == 0)
491 {
493 endptr = num + 9;
494 }
495 else if (pg_strncasecmp(num, "inf", 3) == 0)
496 {
498 endptr = num + 3;
499 }
500 else if (pg_strncasecmp(num, "+inf", 4) == 0)
501 {
503 endptr = num + 4;
504 }
505 else if (pg_strncasecmp(num, "-inf", 4) == 0)
506 {
508 endptr = num + 4;
509 }
510 else if (save_errno == ERANGE)
511 {
512 /*
513 * Some platforms return ERANGE for denormalized numbers (those
514 * that are not zero, but are too close to zero to have full
515 * precision). We'd prefer not to throw error for that, so try to
516 * detect whether it's a "real" out-of-range condition by checking
517 * to see if the result is zero or huge.
518 *
519 * On error, we intentionally complain about double precision not
520 * the given type name, and we print only the part of the string
521 * that is the current number.
522 */
523 if (val == 0.0 || val >= HUGE_VAL || val <= -HUGE_VAL)
524 {
525 char *errnumber = pstrdup(num);
526
527 errnumber[endptr - num] = '\0';
528 ereturn(escontext, 0,
530 errmsg("\"%s\" is out of range for type double precision",
531 errnumber)));
532 }
533 }
534 else
535 ereturn(escontext, 0,
537 errmsg("invalid input syntax for type %s: \"%s\"",
538 type_name, orig_string)));
539 }
540
541 /* skip trailing whitespace */
542 while (*endptr != '\0' && isspace((unsigned char) *endptr))
543 endptr++;
544
545 /* report stopping point if wanted, else complain if not end of string */
546 if (endptr_p)
547 *endptr_p = endptr;
548 else if (*endptr != '\0')
549 ereturn(escontext, 0,
551 errmsg("invalid input syntax for type %s: \"%s\"",
552 type_name, orig_string)));
553
554 return val;
555}
static float8 get_float8_infinity(void)
Definition float.h:68
static float8 get_float8_nan(void)
Definition float.h:87

References ereturn, errcode(), errmsg, fb(), get_float8_infinity(), get_float8_nan(), pg_strncasecmp(), pstrdup(), and val.

Referenced by dependencies_scalar(), executeItemOptUnwrapTarget(), float8in(), and single_decode().

◆ float8out_internal()

char * float8out_internal ( float8  num)
extern

Definition at line 578 of file float.c.

579{
580 char *ascii = (char *) palloc(32);
582
583 if (extra_float_digits > 0)
584 {
586 return ascii;
587 }
588
589 (void) pg_strfromd(ascii, 32, ndig, num);
590 return ascii;
591}
int double_to_shortest_decimal_buf(double f, char *result)
Definition d2s.c:1053
int extra_float_digits
Definition float.c:57
void * palloc(Size size)
Definition mcxt.c:1387
Datum ascii(PG_FUNCTION_ARGS)
int pg_strfromd(char *str, size_t count, int precision, double value)
Definition snprintf.c:1276

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

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

◆ float_overflow_error()

◆ float_overflow_error_ext()

float8 float_overflow_error_ext ( struct Node escontext)
extern

Definition at line 127 of file float.c.

128{
129 ereturn(escontext, 0.0,
131 errmsg("value out of range: overflow"));
132}

References ereturn, errcode(), errmsg, and fb().

Referenced by dtof(), float8_div_safe(), float8_mi_safe(), float8_mul_safe(), and float8_pl_safe().

◆ float_underflow_error()

pg_noreturn void float_underflow_error ( void  )
extern

Definition at line 111 of file float.c.

112{
115 errmsg("value out of range: underflow")));
116}

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

Referenced by dcbrt(), dcosh(), dexp(), dgamma(), dlog1(), dlog10(), dpow(), dsqrt(), float4_div(), and float4_mul().

◆ float_underflow_error_ext()

float8 float_underflow_error_ext ( struct Node escontext)
extern

Definition at line 135 of file float.c.

136{
137 ereturn(escontext, 0.0,
139 errmsg("value out of range: underflow"));
140}

References ereturn, errcode(), errmsg, and fb().

Referenced by dtof(), float8_div_safe(), and float8_mul_safe().

◆ float_zero_divide_error()

pg_noreturn void float_zero_divide_error ( void  )
extern

Definition at line 119 of file float.c.

120{
123 errmsg("division by zero")));
124}

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

Referenced by float4_div().

◆ float_zero_divide_error_ext()

float8 float_zero_divide_error_ext ( struct Node escontext)
extern

Definition at line 143 of file float.c.

144{
145 ereturn(escontext, 0.0,
147 errmsg("division by zero")));
148}

References ereturn, errcode(), errmsg, and fb().

Referenced by float8_div_safe().

◆ get_float4_infinity()

static float4 get_float4_infinity ( void  )
inlinestatic

Definition at line 61 of file float.h.

62{
63 /* C99 standard way */
64 return (float4) INFINITY;
65}

References fb().

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

◆ get_float4_nan()

static float4 get_float4_nan ( void  )
inlinestatic

Definition at line 80 of file float.h.

81{
82 /* C99 standard way */
83 return (float4) NAN;
84}

References fb().

Referenced by float4in_internal(), and numeric_float4().

◆ get_float8_infinity()

◆ get_float8_nan()

◆ is_infinite()

int is_infinite ( float8  val)
extern

Definition at line 159 of file float.c.

160{
161 int inf = isinf(val);
162
163 if (inf == 0)
164 return 0;
165 else if (val > 0)
166 return 1;
167 else
168 return -1;
169}

References fb(), and val.

Variable Documentation

◆ extra_float_digits

PGDLLIMPORT int extra_float_digits
extern

Definition at line 57 of file float.c.

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