Re: Float output formatting options

From: "Pedro M(dot) Ferreira" <pfrazao(at)ualg(dot)pt>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Float output formatting options
Date: 2002-11-04 18:10:12
Message-ID: 3DC6B804.7010705@ualg.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:

> BTW, did you check to see if this affects the geometric types or not?
> I am not sure that they go through float8out; they may need similar
> adjustments in their output routines.

In fact they need adjustments.

The *_out routines (in src/backend/utils/adt/geo_ops.c) for the
geometric types rely on two functions to output data:

static int pair_encode(float8 x, float8 y, char *str);
static int single_encode(float8 x, char *str);

These functions produce output with (for pair_encode):

sprintf(str, "%.*g,%.*g", digits8, x, digits8, y);

digits8 is defined as ,

#define P_MAXDIG DBL_DIG
static int digits8 = P_MAXDIG;

I think it would be done the same way as for float4_out and float8_out:

extern int extra_float_digits;

int
ndig = digits8 + extra_float_digits;

if (ndig < 1)
ndig = 1;

sprintf(str, "%.*g,%.*g", ndig, x, ndig, y);

There a bunch of other places where output is produced. They are all
within #ifdef GEODEBUG / #enfif blocks. Should these be corrected the
same way ?

Regards,
Pedro

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-11-04 18:14:48 Re: Float output formatting options
Previous Message Marc G. Fournier 2002-11-04 18:01:26 v7.3Beta4 Tag'd and Packaged ...