This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/46908] printf not handling printing of double correctly in certain cases


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46908

Adrian Hawryluk <adrian.hawryluk at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |

--- Comment #3 from Adrian Hawryluk <adrian.hawryluk at gmail dot com> 2010-12-12 22:53:43 UTC ---
Sorry, changed to %Lf with same results.   

#include <stdio.h>
#include <math.h>
void printld(long double* pld)
{
    int i;
    printf("*%p = ", pld);
    for (i = 0; i < sizeof(long double); ++i) {
        printf("%02x ", ((unsigned char*)pld)[i]);
    }
    printf("\n");
}

int main()
{
    long double number1 = 1.0;
    long double number2 = 1.0;

    printf ("%Lf, %Lf\n", number1, number2);

    printf ("Enter number1: ");
    scanf (" %Lf", &number1);
    printf ("Enter number2: ");
    scanf (" %Lf", &number2);

    printf ("%Lf, %Lf\n", number1, number2);
    printf ("%Lf, %Lf\n", number1, number1);

    printld(&number1);
    printld(&number2);
    return 0;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]