delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/06/14/07:20:53

Date: Tue, 14 Jun 1994 12:59:31 +0200 (CED)
From: David Svensson <david AT df DOT lth DOT se>
Subject: Re: using scanf to read long double?
To: "Grzegorz B. Mazur" <gbm AT ii DOT pw DOT edu DOT pl>
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu

On Tue, 14 Jun 1994, Grzegorz B. Mazur wrote:
> 
> First, the compiler has NO RIGHT to check the args for scanf, because it
> doesn't know what is scanf, and how the format string for it should look.

GNU's gcc, and therefore DJGPP, is in fact capable of checking the
parameters to scanf, printf and their likes. When invoked with the
-Wformat option gcc will treat them as special keywords and check for
correct parameters.

> I am not quite sure if GCC supports long double on 386 (80 bits is not 
> a very typical format...) 

80 bits is in fact one of the most commonly used floating point sizes of the 
387. That is, 64 bits mantissa and the rest is the exponent.

> - it can be treated as double. If this is the case,
> everything works OK...

Unfortunately this isn't the case. DJGPP uses a 53 bit mantissa for 
double and a 64 bit mantissa for long double. This is unfortunate since 
I'm porting an application from Turbo C, which allows 
scanf("%Lf",&my_long_double). The added precision is really needed.

Looks like I'll have to write my own long double parser. Sigh...

David


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019