public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Atakan Gurkan <ato@northwestern.edu>
To: gsl-discuss@sources.redhat.com
Subject: Re: problems with long double data type...
Date: Tue, 12 Nov 2002 09:08:00 -0000	[thread overview]
Message-ID: <20021112110229.A25618@chinook.phys.nwu.edu> (raw)
In-Reply-To: <F164LqY54z3r5vzfHsm0000660f@hotmail.com>; from gabrielgoenaga@hotmail.com on Tue, Nov 12, 2002 at 02:45:42PM +0000

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 <stdio.h>

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

  reply	other threads:[~2002-11-12 17:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-12  9:04 Gabriel Andres Goenaga Jimenez
2002-11-12  9:08 ` Atakan Gurkan [this message]
2002-11-12 10:08   ` Atakan Gurkan
2002-11-12  9:05 Trevor Blackwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021112110229.A25618@chinook.phys.nwu.edu \
    --to=ato@northwestern.edu \
    --cc=gsl-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).