Thread: 128 bit (long double) printf not working

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2016
    Posts
    14

    128 bit (long double) printf not working

    I have run the following code to see what my computer's byte size is for each data type:

    Code:
    #include <stdio.h>
    #include <limits.h>
    
    int main()
    {
        printf("The size of char in bytes is: %llu.", sizeof(char));
        printf("\nThe size of short in bytes is: %llu.", sizeof(short));
        printf("\nThe size of int in bytes is: %llu.", sizeof(int));
        printf("\nThe size of long in bytes is: %llu.", sizeof(long));
        printf("\nThe size of long long in bytes is: %llu.", sizeof(long long));
        printf("\nThe size of float in bytes is: %llu.", sizeof(float));
        printf("\nThe size of double in bytes is: %llu.", sizeof(double));
        printf("\nThe size of long double in bytes is: %llu.", sizeof(long double));
        
        return 0;
    }
    128 bit (long double) printf not working-capture-png

    However, when I try to use printf for long double, it always prints the same junk exponent value regardless of what the variable is set to in the program.

    Code:
    #include <stdio.h>
    
    int main()
    {
        long double x = 3.1415;
    
        printf("%Lg", x);
        
        return 0;
    }
    128 bit (long double) printf not working-capture1-png


    I have read on the internet forums that this is either a printf limitation or a compiler issue or some combination of these. I am using a MinGW GCC 6.1.0 compiler on a 64-bit Windows PC.

    How do I fix this? Do I need to get a different compiler or is there another C function that can print this 16-bit (or 20-bit) long double properly?
    Attached Images Attached Images 128 bit (long double) printf not working-capture-png 
    Last edited by AamirYousafi; 06-28-2016 at 02:57 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 06-07-2015, 03:28 PM
  2. 'long long' type and printf() (on AIX 5.3)
    By alex5161 in forum C Programming
    Replies: 5
    Last Post: 12-16-2011, 04:05 PM
  3. number bigger than long long double
    By suryak in forum C Programming
    Replies: 9
    Last Post: 08-18-2011, 02:02 PM
  4. Replies: 1
    Last Post: 04-23-2011, 08:40 PM
  5. printf not working with long type
    By that_guy1 in forum C Programming
    Replies: 2
    Last Post: 10-15-2005, 05:37 PM

Tags for this Thread