Re: Float output formatting options - Mailing list pgsql-hackers

From Pedro M. Ferreira
Subject Re: Float output formatting options
Date
Msg-id 3DC6B804.7010705@ualg.pt
Whole thread Raw
In response to Float output formatting options  ("Pedro M. Ferreira" <pfrazao@ualg.pt>)
Responses Re: Float output formatting options  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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



pgsql-hackers by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: v7.3Beta4 Tag'd and Packaged ...
Next
From: Tom Lane
Date:
Subject: Re: Float output formatting options