Re: [HACKERS] float output precision questions

2002-11-07 Thread Bruce Momjian
Added to TODO: * Add GUC variables extra_float_digits and extra_double_digits to control output digits --- Tom Lane wrote: > "Pedro M. Ferreira" <[EMAIL PROTECTED]> writes: > > Have two parameters, say DOUBL

Re: [HACKERS] float output precision questions

2002-10-31 Thread Tom Lane
Bruno Wolff III <[EMAIL PROTECTED]> writes: > If the normal number of digits displayed is different between two systems, > than displaying a fixed number less digits is still going to result in > differences. That is, however, not the problem we have with the geometry test.

Re: [HACKERS] float output precision questions

2002-10-31 Thread Bruno Wolff III
On Thu, Oct 31, 2002 at 12:58:21 -0500, Tom Lane <[EMAIL PROTECTED]> wrote: > > But I think an EXTRA_DIGITS setting might be interesting. In > particular, suppose we allowed EXTRA_DIGITS to be negative? Setting > it to -1 or -2 would go a long way towards eliminating our problems > with platfo

Re: [HACKERS] float output precision questions

2002-10-31 Thread Pedro M. Ferreira
I sent an email before receiving the one below. I am happier also with the extra_digits way (from the previous email I thought the options were DBL_DIG or DBL_DIG+2). I'm not happy with adding the hex-output option, since it's not very portable and doesn't seem necessary to solve the problem any

Re: [HACKERS] float output precision questions

2002-10-31 Thread Pedro M. Ferreira
Tom Lane wrote: Bottom line: if DBL_DIG=15 and the float arithmetic is binary, then there are some double values that require 17 displayed digits to distinguish, even though not all 16-digit numbers are distinct. So I retract my original proposal and instead suggest that we offer a switch to dis

Re: [HACKERS] float output precision questions

2002-10-31 Thread Tom Lane
"Pedro M. Ferreira" <[EMAIL PROTECTED]> writes: > Have two parameters, say DOUBLE_OUTPUT and EXTRA_DIGITS. DOUBLE_OUTPUT > would select from decimal output or normalized output. EXTRA_DIGITS > would add the required extra digits, from 0 (default) to 3, when output > is decimal. I'm not happy w

Re: [HACKERS] float output precision questions

2002-10-31 Thread Pedro M. Ferreira
Tom Lane wrote: I was misremembering these papers to claim DBL_DIG+1 is enough, but actually they prove that DBL_DIG+2 is necessary and sufficient (and give code to do it correctly, too). Yeahh! If there's a proof its safe to implement. I also Googled a bit and found another paper saying that 1

Re: [HACKERS] float output precision questions

2002-10-31 Thread Tom Lane
"Pedro M. Ferreira" <[EMAIL PROTECTED]> writes: > Its like I said before, the guys from matlab (in x86 IEEE float) go to > DBL_BIG+3 to have 'maximum precision'. Apparently they have not read the canonical papers in the field. [ googles for a moment... ] See How to read floating point numbers

Re: [HACKERS] float output precision questions

2002-10-31 Thread Tom Lane
"Pedro M. Ferreira" <[EMAIL PROTECTED]> writes: > Zeugswetter Andreas SB SD wrote: >> Unfortunately %A is not portable :-( > What do you mean ? Just what he said. > It is C99, introduced in glibc 2.1. > What are the requirements for PostgreSQL ? glibc does not define the universe; nor are all

Re: [HACKERS] float output precision questions

2002-10-31 Thread Tom Lane
Stephan Szabo <[EMAIL PROTECTED]> writes: > On Wed, 30 Oct 2002, Tom Lane wrote: >> sprintf(ascii, "%.*g", DBL_DIG+1, num); >> and similarly for float4. Given carefully written float I/O routines, >> reading the latter output should reproduce the originally stored value. > Well, on my system, it

Re: [HACKERS] float output precision questions

2002-10-31 Thread Pedro M. Ferreira
Zeugswetter Andreas SB SD wrote: Yes agree (or double_significant_digits or format_double_digits ?), but default to DBL_DIG and allow range between 1 and DBL_DIG + 3. format_* could be used for all future output format tweaks. Unfortunately %A is not portable :-( What do you mean ? It is C99,

Re: [HACKERS] float output precision questions

2002-10-31 Thread Zeugswetter Andreas SB SD
> Maybe it makes sense that in the proposal below the parameter > EXTRA_DIGITS could be SIGNIFICANT_DIGITS with a default value > of 15 and maximum 18. > Its more 'documentable' and maybe easy to understand in general. Yes agree (or double_significant_digits or format_double_digits ?), but def

Re: [HACKERS] float output precision questions

2002-10-31 Thread Pedro M. Ferreira
Just one more note, Maybe it makes sense that in the proposal below the parameter EXTRA_DIGITS could be SIGNIFICANT_DIGITS with a default value of 15 and maximum 18. Its more 'documentable' and maybe easy to understand in general. Pedro M. Ferreira wrote: Yes. I think there are several option

Re: [HACKERS] float output precision questions

2002-10-31 Thread Pedro M. Ferreira
Tom Lane wrote: My recollection is that other people (perhaps Peter?) were the ones objecting before. However I'd be somewhat unhappy with the proposal as given: Option 'SHORT' would be default and produce the standard sprintf(ascii,... Option 'LONG' would produce sprintf(ascii, "%25.18g", num

Re: [HACKERS] float output precision questions

2002-10-30 Thread Stephan Szabo
On Wed, 30 Oct 2002, Tom Lane wrote: > Stephan Szabo <[EMAIL PROTECTED]> writes: > > On Wed, 30 Oct 2002, Pedro M. Ferreira wrote: > >> I looked at some of these emails and it seemed to me that the problem > >> was that Tom did'nt want a parameter that would force people to know > >> about printf

Re: [HACKERS] float output precision questions

2002-10-30 Thread Tom Lane
Stephan Szabo <[EMAIL PROTECTED]> writes: > On Wed, 30 Oct 2002, Pedro M. Ferreira wrote: >> I looked at some of these emails and it seemed to me that the problem >> was that Tom did'nt want a parameter that would force people to know >> about printf number formatting. I think the first solution ab

Re: [HACKERS] float output precision questions

2002-10-30 Thread Stephan Szabo
On Wed, 30 Oct 2002, Pedro M. Ferreira wrote: > Stephan Szabo wrote: > > On Wed, 30 Oct 2002, Pedro Miguel Frazao Fernandes Ferreira wrote: > >> > >>I understand that if people insert a value of 1.1 in a double, they want > >>to get 1.1 without knowing that in fact the stored number is > >>1.1000

Re: [HACKERS] float output precision questions

2002-10-30 Thread Pedro M. Ferreira
Stephan Szabo wrote: On Wed, 30 Oct 2002, Pedro Miguel Frazao Fernandes Ferreira wrote: I understand that if people insert a value of 1.1 in a double, they want to get 1.1 without knowing that in fact the stored number is 1.10009. But do you understand that if some people insert, for

Re: [HACKERS] float output precision questions

2002-10-30 Thread Bruno Wolff III
On Wed, Oct 30, 2002 at 19:27:57 +0100, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > > The printf("%A") output is not system-specific. Just out of curiosity, can you tell me a web page or keywords to use in a search to see what that format does? I tried using google, but searching for printf w

Re: [HACKERS] float output precision questions

2002-10-30 Thread Stephan Szabo
On Wed, 30 Oct 2002, Pedro Miguel Frazao Fernandes Ferreira wrote: > In C this is possible: > > #include > #include > > int main(void) > { >double v; >char a[30]; > >v=1.79769313486231571e+308; > >printf(" Stored double number: %25.18g\n",v); >sprintf(a,"%25.18g",v)

Re: [HACKERS] float output precision questions

2002-10-30 Thread Peter Eisentraut
Bruno Wolff III writes: > On Tue, Oct 29, 2002 at 23:19:05 +0100, > Peter Eisentraut <[EMAIL PROTECTED]> wrote: > > > > There isn't a way right now, but it's planned to be able to dump > > floating-point numbers in some binary form (like printf("%A")) to be able > > to restore them exactly. Not

Re: [HACKERS] float output precision questions

2002-10-30 Thread Pedro Miguel Frazao Fernandes Ferreira
Stephan Szabo wrote: On Wed, 30 Oct 2002, Pedro Miguel Frazao Fernandes Ferreira wrote: Stephan Szabo wrote: On Tue, 29 Oct 2002, Peter Eisentraut wrote: Pedro Miguel Frazao Fernandes Ferreira writes: Is there a way to set query output precision to maximum precision ? For the type of applicati

Re: [HACKERS] float output precision questions

2002-10-30 Thread Stephan Szabo
On Wed, 30 Oct 2002, Pedro Miguel Frazao Fernandes Ferreira wrote: > Stephan Szabo wrote: > > On Tue, 29 Oct 2002, Peter Eisentraut wrote: > > > > > >>Pedro Miguel Frazao Fernandes Ferreira writes: > >> > >> > >>>Is there a way to set query output precision to maximum precision ? > >>>For the typ

Re: [HACKERS] float output precision questions

2002-10-30 Thread Pedro Miguel Frazao Fernandes Ferreira
Bruno Wolff III wrote: On Tue, Oct 29, 2002 at 23:19:05 +0100, Peter Eisentraut <[EMAIL PROTECTED]> wrote: There isn't a way right now, but it's planned to be able to dump floating-point numbers in some binary form (like printf("%A")) to be able to restore them exactly. Not sure how that woul

Re: [HACKERS] float output precision questions

2002-10-30 Thread Pedro Miguel Frazao Fernandes Ferreira
Stephan Szabo wrote: On Tue, 29 Oct 2002, Peter Eisentraut wrote: Pedro Miguel Frazao Fernandes Ferreira writes: Is there a way to set query output precision to maximum precision ? For the type of application I mentioned this is crucial. People want to get the 'same' numbers, from querys or

Re: [HACKERS] float output precision questions

2002-10-30 Thread Pedro Miguel Frazao Fernandes Ferreira
Peter Eisentraut wrote: Matlab has a toolbox fucntion, claiming maximum precision, to convert from its double type (PostgreSQL float8) to string which does a sprintf('%25.18g',number). Do we have some mathematical guarantee that this is sufficient and necessary? If so, then it might do.

Re: [HACKERS] float output precision questions

2002-10-29 Thread Bruno Wolff III
On Tue, Oct 29, 2002 at 23:19:05 +0100, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > > There isn't a way right now, but it's planned to be able to dump > floating-point numbers in some binary form (like printf("%A")) to be able > to restore them exactly. Not sure how that would satisfy the nee

Re: [HACKERS] float output precision questions

2002-10-29 Thread Stephan Szabo
On Tue, 29 Oct 2002, Peter Eisentraut wrote: > Pedro Miguel Frazao Fernandes Ferreira writes: > > > Is there a way to set query output precision to maximum precision ? > > For the type of application I mentioned this is crucial. People want to > > get the 'same' numbers, from querys or dumps, as t

Re: [HACKERS] float output precision questions

2002-10-29 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > TODO has: >o Add SET REAL_FORMAT and SET DOUBLE_PRECISION_FORMAT >using printf args > so we have not implemented it yet. IIRC, the last time it was discussed there was disagreement about how it should work; check the pghackers archives fo

Re: [HACKERS] float output precision questions

2002-10-29 Thread Peter Eisentraut
Pedro Miguel Frazao Fernandes Ferreira writes: > Is there a way to set query output precision to maximum precision ? > For the type of application I mentioned this is crucial. People want to > get the 'same' numbers, from querys or dumps, as they inserted them. There isn't a way right now, but it

Re: [HACKERS] float output precision questions

2002-10-29 Thread Bruce Momjian
TODO has: o Add SET REAL_FORMAT and SET DOUBLE_PRECISION_FORMAT using printf args so we have not implemented it yet. --- Pedro Miguel Frazao Fernandes Ferreira wrote: > Hi All, > > I wrote a Matlab interfa

Re: [HACKERS] float output precision questions

2002-10-29 Thread Pedro Miguel Frazao Fernandes Ferreira
Sorry. I forgot to thank for any help from all of you in the previous message. Thanks! :) Just one more thing: I now I can go to the source and change the code which converts floats to strings, and have my problem solved. But this wont be general. Others might need this kind of application.

[HACKERS] float output precision questions

2002-10-29 Thread Pedro Miguel Frazao Fernandes Ferreira
Hi All, I wrote a Matlab interface to PostgreSQL based on libpq. It is working fine, supports multiple connections, supports all data types and arrays. It is a C program to do the interface and some Matlab wrapper functions around it to do the job at application level. Matlab has an ODBC toolb