PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwprint_double()

int lwprint_double ( double  d,
int  maxdd,
char *  buf,
size_t  bufsize 
)

Definition at line 492 of file lwprint.c.

493{
494 double ad = fabs(d);
495 int ndd;
496 int length = 0;
497 if (ad <= FP_TOLERANCE)
498 {
499 d = 0;
500 ad = 0;
501 }
502 if (ad < OUT_MAX_DOUBLE)
503 {
504 ndd = ad < 1 ? 0 : floor(log10(ad)) + 1; /* non-decimal digits */
505 if (maxdd > (OUT_MAX_DOUBLE_PRECISION - ndd)) maxdd -= ndd;
506 length = snprintf(buf, bufsize, "%.*f", maxdd, d);
507 }
508 else
509 {
510 length = snprintf(buf, bufsize, "%g", d);
511 }
513 return length;
514}
#define OUT_MAX_DOUBLE
#define FP_TOLERANCE
Floating point comparators.
#define OUT_MAX_DOUBLE_PRECISION
static void trim_trailing_zeros(char *str)
Definition lwprint.c:448

References FP_TOLERANCE, OUT_MAX_DOUBLE, OUT_MAX_DOUBLE_PRECISION, and trim_trailing_zeros().

Referenced by assvg_point_buf(), pointArray_svg_abs(), pointArray_svg_rel(), pointArray_to_geojson(), pointArray_toGML2(), pointArray_toGML3(), ptarray_to_wkt_sb(), and ptarray_to_x3d3_sb().

Here is the call graph for this function:
Here is the caller graph for this function: