From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | "Pedro M(dot) Ferreira" <pfrazao(at)ualg(dot)pt> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Float output formatting options |
Date: | 2002-11-08 04:50:44 |
Message-ID: | 200211080450.gA84oiS00137@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I am confused about this patch. I don't see extra_float_digits defined
anywhere. Am I missing a patch?
---------------------------------------------------------------------------
Pedro M. Ferreira wrote:
> Pedro M. Ferreira wrote:
> > Tom Lane wrote:
> >> Perhaps P_MAXLEN now needs to be (2*(DBL_DIG+2+7)+1), considering
> >> that we'll allow extra_float_digits to be up to 2. What's it used for?
> >
> > Yes. I guess so, because it is used in what I think is a memory
> > allocation function. P_MAXLEN is only used twice:
> <...>
> >
> > I will do the changes tomorrow and send in the appropriate diff's.
>
> Ok. Its done now.
> Only one file changed: src/backend/utils/adt/geo_ops.c
>
> All the geometric types should now account for float_extra_digits on output.
>
> A diff -u is attached.
>
> Best reagards,
> Pedro
>
> > Regards,
> > Pedro
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 2: you can get off all lists at once with the unregister command
> > (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
> >
> >
>
>
> --
> ----------------------------------------------------------------------
> Pedro Miguel Frazao Fernandes Ferreira
> Universidade do Algarve
> Faculdade de Ciencias e Tecnologia
> Campus de Gambelas
> 8000-117 Faro
> Portugal
> Tel./Fax: (+351) 289 800950 / 289 819403
> http://w3.ualg.pt/~pfrazao
> --- old/postgresql-7.2.1/src/backend/utils/adt/geo_ops.c Mon Nov 4 12:01:39 2002
> +++ postgresql-7.2.1/src/backend/utils/adt/geo_ops.c Tue Nov 5 10:47:56 2002
> @@ -80,11 +80,11 @@
> #define RDELIM_C '>'
>
> /* Maximum number of output digits printed */
> -#define P_MAXDIG DBL_DIG
> -#define P_MAXLEN (2*(P_MAXDIG+7)+1)
> -
> -static int digits8 = P_MAXDIG;
> +/* ...+2+7 : 2 accounts for extra_float_digits max value */
> +#define P_MAXLEN (2*(DBL_DIG+2+7)+1)
>
> +/* Extra digits in float output formatting (in float.c) */
> +extern int extra_float_digits;
>
> /*
> * Geometric data types are composed of points.
> @@ -139,7 +139,12 @@
> static int
> single_encode(float8 x, char *str)
> {
> - sprintf(str, "%.*g", digits8, x);
> + int ndig = DBL_DIG + extra_float_digits;
> +
> + if (ndig < 1)
> + ndig=1;
> +
> + sprintf(str, "%.*g", ndig, x);
> return TRUE;
> } /* single_encode() */
>
> @@ -190,7 +195,12 @@
> static int
> pair_encode(float8 x, float8 y, char *str)
> {
> - sprintf(str, "%.*g,%.*g", digits8, x, digits8, y);
> + int ndig = DBL_DIG + extra_float_digits;
> +
> + if (ndig < 1)
> + ndig=1;
> +
> + sprintf(str, "%.*g,%.*g", ndig, x, ndig, y);
> return TRUE;
> }
>
> @@ -974,7 +984,7 @@
> #endif
> #ifdef GEODEBUG
> printf("line_construct_pts- line is neither vertical nor horizontal (diffs x=%.*g, y=%.*g\n",
> - digits8, (pt2->x - pt1->x), digits8, (pt2->y - pt1->y));
> + DBL_DIG, (pt2->x - pt1->x), DBL_DIG, (pt2->y - pt1->y));
> #endif
> }
> }
> @@ -1180,8 +1190,8 @@
>
> #ifdef GEODEBUG
> printf("line_interpt- lines are A=%.*g, B=%.*g, C=%.*g, A=%.*g, B=%.*g, C=%.*g\n",
> - digits8, l1->A, digits8, l1->B, digits8, l1->C, digits8, l2->A, digits8, l2->B, digits8, l2->C);
> - printf("line_interpt- lines intersect at (%.*g,%.*g)\n", digits8, x, digits8, y);
> + DBL_DIG, l1->A, DBL_DIG, l1->B, DBL_DIG, l1->C, DBL_DIG, l2->A, DBL_DIG, l2->B, DBL_DIG, l2->C);
> + printf("line_interpt- lines intersect at (%.*g,%.*g)\n", DBL_DIG, x, DBL_DIG, y);
> #endif
>
> return result;
> @@ -2390,14 +2400,14 @@
> p = line_interpt_internal(&tmp, line);
> #ifdef GEODEBUG
> printf("interpt_sl- segment is (%.*g %.*g) (%.*g %.*g)\n",
> - digits8, lseg->p[0].x, digits8, lseg->p[0].y, digits8, lseg->p[1].x, digits8, lseg->p[1].y);
> + DBL_DIG, lseg->p[0].x, DBL_DIG, lseg->p[0].y, DBL_DIG, lseg->p[1].x, DBL_DIG, lseg->p[1].y);
> printf("interpt_sl- segment becomes line A=%.*g B=%.*g C=%.*g\n",
> - digits8, tmp.A, digits8, tmp.B, digits8, tmp.C);
> + DBL_DIG, tmp.A, DBL_DIG, tmp.B, DBL_DIG, tmp.C);
> #endif
> if (PointerIsValid(p))
> {
> #ifdef GEODEBUG
> - printf("interpt_sl- intersection point is (%.*g %.*g)\n", digits8, p->x, digits8, p->y);
> + printf("interpt_sl- intersection point is (%.*g %.*g)\n", DBL_DIG, p->x, DBL_DIG, p->y);
> #endif
> if (on_ps_internal(p, lseg))
> {
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2002-11-08 04:54:19 | Re: Win32 port |
Previous Message | Bruce Momjian | 2002-11-08 04:29:18 | Re: Concerns about statement-timeout patch |