Discussion on openssl-dev and some checks on my part showed that it was 
in fact a problem in OpenSSL.  I just committed a fix, so it would be 
appropriate to check with tomorrows snapshot.

Ticket resolved.

[EMAIL PROTECTED] - Thu Dec 11 11:06:43 2003]:

> > > #include <stdio.h>
> > > #include "openssl/bio.h"
> > >
> > >
> > > int main(int argc, char* argv[])
> > > {
> > >     BIO *myBio = BIO_new_fp(stdout, 0);
> > >     BIO_printf(myBio, "float: %.1f\n", (float) 1000.1234);
> > >     return 0;
> > > }
> > >
> > >
> > > When I run this against either of our builds of 0.9.7c (or b) on
> HP-UX
> > > (PA and IA) the output of the above program will be "float: 000.1"
> > > Note
> > > that the front part of the whole value is cut off.
> > >
> > > This does not occur on Linux.
> >
> > That is not correct, it does also occur on my Linux box.
> 
> I can't reproduce it on my Linux box...
> 
> > Anyway, the problem is not with OpenSSL but with your code. When
> > performing printf() (variable argument list functions without a
> > protototype to specify the particular data type), a float value will
> be
> > promoted to a double and the printf formatting functions therefore
> > expect a double value (8 byte) to be available. By casting your data
> > explicitly to (float), only a 4 bit value is passed that is
> > misinterpreted by the %f printing routine.
> 
> The last statement is false. ANSI C behaviour is to promote floats to
> doubles whenever in doubt. Given that BIO_printf is declared with ...,
> ellipsis, (float)1000.1234 should be compiled as
> (double)(float)1000.1234. Moreover, you can actually see that it *is*
> compiled as (double)(float)1000.1234, because otherwise printout
> wouldn't be 000.1, but a garbage value. No, I don't have explanation
> for
> the phenomena, but I can't find the presented analysis conclusive:-)
> A.
> 


-- 
Richard Levitte
[EMAIL PROTECTED]
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to