On Thu, 25 Oct 2018, Rajalakshmi Srinivasaraghavan wrote: > + if (__builtin_unpack_longdouble (a, 0) < TWO53) > + { > + /* In this case the integer portion is completely contained > + within the high double. So use the hardware convert to > + integer doubleword, and then extend to int. */ > + l1 = __builtin_unpack_longdouble (a, 0); > + result = l1;
But if the high double is a positive integer, and the low double is strictly negative (not -0), you need to subtract 1 to get a result that's correctly truncated towards zero. > + if (__builtin_unpack_longdouble (a, 0) < TWO53) > + { > + /* In this case the integer portion is completely contained > + within the high double. So use the hardware convert to > + integer doubleword, and then extend to __int128. */ > + l1 = __builtin_unpack_longdouble (a, 0); > + result = l1; Likewise here. -- Joseph S. Myers jos...@codesourcery.com