[EMAIL PROTECTED] - Thu Dec 11 08:16:12 2003]:

> I have a simple program that uses the BIO printf functionality:
> 
> #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.
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.

Best regards,
     Lutz
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to