The common long double
implementation cannot represent all 20-digit decimal numbers exactly.
The characteristics of long double
are not completely determined by the C++ standard, and you do not state what implementation you are using.
One common implementation of long double
uses a 64-bit significand. Although it may be stored in twelve bytes, it uses only ten, and 16 of those are used for the sign and exponent, leaving 64 for the significand (including an explicit leading bit).
A 64-bit significand can represent integers without error up to 264, which is about 1.845•1019. Thus, it cannot represent all 20-digit numbers exactly.