From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: long doubles and NaNs Date: Mon, 16 Jun 1997 19:25:11 +0000 Organization: Two pounds of chaos and a pinch of salt Lines: 39 Message-ID: <33A59317.EC2@cs.com> References: <33A57964 DOT 4C1D AT ior DOT unizh DOT ch> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp107.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk matteotti carlo wrote: > > I'm a beginner with C++ and I just started with DJGPP. > As a little exercise I've written a stupid little "program" which > should read a "real number" as a long double and write this number > back to the screen again. But what I get back is just "-NaN". > How can I convince the program that e.g. 1.13245 is indeed a number ?? Can you post sample code? Specifically, how are you declaring the variable, how are you passing it to scanf(), and how are you printing it? Here's an example: #include int main( void ) { long double ld; printf( "Enter a decimal number: " ); if ( scanf( "%Lf", &ld ) == 1 ) printf( "You entered %Lf.\n", ld ); else printf( "That's not a number.\n" ); return 0; } P.S.: Please post general programming questions on comp.lang.c or comp.lang.c.moderated, or get a good C reference book. hth -- --------------------------------------------------------------------- | John M. Aldrich | "Sex should be friendly. Otherwise | | aka Fighteer I | stick to mechanical toys; it's more | | mailto:fighteer AT cs DOT com | sanitary." | | http://www.cs.com/fighteer | - Lazarus Long | ---------------------------------------------------------------------