Search code examples
cfloating-pointdoubleprecision

Long Double vs Long Long


I know this may seem too simple of a question but I'm having difficulty wrapping my head around the meaning/implication of double & long. All online resources are giving official definitions. I'm looking for a layman's explanation.

In Short, my question is: What is the difference between a long long, a long double & a long float?

I tried running a quick test (screenshot attached) to see the byte size of each type, but couldn't make sense out of it. How is a long double same size as a double?

enter image description here


Solution

  • long long is integer (possibly with more range than long)
    long double is floating point (possibly with more range/precision than double)
    long float does not exist.

    The integer types sorted by range are

    • _Bool
    • char or signed char or unsigned char
    • short (or short int) or short unsigned
    • int or unsigned
    • long (or long int) or long unsigned
    • long long (or long long int) or long long unsigned

    The floating-point types sorted by range/precision are

    • float
    • double
    • long double