Lines Matching full:double
1 //===-- lib/builtins/ppc/fixunstfti.c - Convert long double->int128 *-C -*-===//
9 // This file implements converting the 128bit IBM/PowerPC long double (double-
10 // double) data type to an unsigned 128 bit integer.
17 // Convert long double into an unsigned 128-bit integer.
18 __uint128_t __fixunstfti(long double input) { in __fixunstfti()
28 // The long double representation, with the high and low portions of in __fixunstfti()
29 // the long double, and the corresponding bit patterns of each double. in __fixunstfti()
31 long double ld; in __fixunstfti()
32 double d[2]; // [0] is the high double, [1] is the low double. in __fixunstfti()
36 // If the long double is less than 1.0 or negative, in __fixunstfti()
49 // Convert each double into int64; they will be added to the int128 result. in __fixunstfti()
50 // CASE 1: High or low double fits in int64 in __fixunstfti()
51 // - Convert the each double normally into int64. in __fixunstfti()
53 // CASE 2: High or low double does not fit in int64 in __fixunstfti()
54 // - Scale the double to fit within a 64-bit integer in __fixunstfti()
55 // - Calculate the shift (amount to scale the double by in the int128) in __fixunstfti()
58 // - Scale (move) the double to the correct place in the int128 in __fixunstfti()
61 // Note: If the high double is assumed to be positive, an unsigned conversion in __fixunstfti()
62 // from long double to 64-bit integer is needed. The low double can be either in __fixunstfti()
64 // of the low double and to ensure it does not simply get converted to 0. in __fixunstfti()
66 // CASE 1 - High double fits in int64. in __fixunstfti()
70 // CASE 2 - High double does not fit in int64, scale and convert it. in __fixunstfti()
78 // double is greater than 128 bits and when the long double in __fixunstfti()
90 // CASE 1 - Low double fits in int64. in __fixunstfti()
94 // CASE 2 - Low double does not fit in int64, scale and convert it. in __fixunstfti()
102 // If the low double is negative, it may change the integer value of the in __fixunstfti()
104 // the fractional part of the high double. Because both doubles cannot in __fixunstfti()
105 // overlap, this situation only occurs when the high double has no in __fixunstfti()
108 if ((ldUnion.d[0] == (double)hiResult) && in __fixunstfti()
109 (ldUnion.d[1] < (double)((__int128_t)loResult))) in __fixunstfti()