Separates x and y into into fractional and whole parts.
| 208 | |
| 209 | // Separates x and y into into fractional and whole parts. |
| 210 | inline void SeparateFractional(int128_t x, int x_scale, int128_t y, int y_scale, |
| 211 | int128_t* x_left, int128_t* x_right, int128_t* y_left, int128_t* y_right) { |
| 212 | // The whole part. |
| 213 | *x_left = x / DecimalUtil::GetScaleMultiplier<int128_t>(x_scale); |
| 214 | *y_left = y / DecimalUtil::GetScaleMultiplier<int128_t>(y_scale); |
| 215 | // The fractional part. |
| 216 | *x_right = x % DecimalUtil::GetScaleMultiplier<int128_t>(x_scale); |
| 217 | *y_right = y % DecimalUtil::GetScaleMultiplier<int128_t>(y_scale); |
| 218 | // Scale up the fractional part of the operand with the smaller scale so that |
| 219 | // the scales match match. |
| 220 | if (x_scale < y_scale) { |
| 221 | *x_right *= DecimalUtil::GetScaleMultiplier<int128_t>(y_scale - x_scale); |
| 222 | } else { |
| 223 | *y_right *= DecimalUtil::GetScaleMultiplier<int128_t>(x_scale - y_scale); |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | // Adds numbers that are large enough so they can't be added directly. Both |
| 228 | // numbers must be either positive or zero. |
no outgoing calls
no test coverage detected