From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17125 invoked by alias); 12 Nov 2002 17:05:11 -0000 Mailing-List: contact gsl-discuss-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gsl-discuss-owner@sources.redhat.com Received: (qmail 17116 invoked from network); 12 Nov 2002 17:05:09 -0000 Received: from unknown (HELO chinook.phys.nwu.edu) (129.105.206.190) by sources.redhat.com with SMTP; 12 Nov 2002 17:05:09 -0000 Received: (from ato@localhost) by chinook.phys.nwu.edu (8.11.6/8.11.6) id gACH2TI25657 for gsl-discuss@sources.redhat.com; Tue, 12 Nov 2002 11:02:29 -0600 Date: Tue, 12 Nov 2002 09:08:00 -0000 From: Atakan Gurkan To: gsl-discuss@sources.redhat.com Subject: Re: problems with long double data type... Message-ID: <20021112110229.A25618@chinook.phys.nwu.edu> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from gabrielgoenaga@hotmail.com on Tue, Nov 12, 2002 at 02:45:42PM +0000 X-SW-Source: 2002-q4/txt/msg00136.txt.bz2 On Tue, Nov 12, 2002 at 02:45:42PM +0000, Gabriel Andres Goenaga Jimenez wrote: > I have working with long double data type. When I try to print the content > of variables with printf or fprintf the data are printed like double type > (in the 1e-307 to 1e+307). I'm compiling my program with gcc in Linux > redhat 7.3, my cpu is a Pentium II. Anybody know what is the problem. I > think may be the compiler, because when I try to the same in borland c++ for > dos it work well, other posibilitie is that the function prinft cannot work > with this data type, but I could'nt find a solution. > > Please, help me. > Hi, I don't know if stdio.h in RH7.3 is suitable for printing long double but installing GSL from scratch would require you to run configure script that checks this. In the meanwhile, assuming you need precision rather than large exponents, you might try something like this: #include int main(){ long double pi; pi = 3.14159265358979323; /* this is outside double precision limit */ printf("%24.18f\n", (double) pi); return 0; } this will print correct value of pi to double precision. If you need to print results to long double precision, you most likely need to recompile your C library. If you need large exponents then the solution above will overflow (or underflow) so you need to check and rescale your numbers before casting them into double. BTW, this question looks more appropiate for a C or GCC discussion group. cheers, ato