MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / round

Function round

app/src/ThirdParty/fast_float.h:4138–4169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4136// round an extended-precision float to the nearest machine float.
4137template <typename T, typename callback>
4138fastfloat_really_inline FASTFLOAT_CONSTEXPR14 void round(adjusted_mantissa &am,
4139 callback cb) noexcept {
4140 int32_t mantissa_shift = 64 - binary_format<T>::mantissa_explicit_bits() - 1;
4141 if (-am.power2 >= mantissa_shift) {
4142 // have a denormal float
4143 int32_t shift = -am.power2 + 1;
4144 cb(am, (shift < 64 ? shift : 64));
4145 // check for round-up: if rounding-nearest carried us to the hidden bit.
4146 am.power2 = (am.mantissa <
4147 (uint64_t(1) << binary_format<T>::mantissa_explicit_bits()))
4148 ? 0
4149 : 1;
4150 return;
4151 }
4152
4153 // have a normal float, use the default shift.
4154 cb(am, mantissa_shift);
4155
4156 // check for carry
4157 if (am.mantissa >=
4158 (uint64_t(2) << binary_format<T>::mantissa_explicit_bits())) {
4159 am.mantissa = (uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
4160 am.power2++;
4161 }
4162
4163 // check for infinite: we could have carried to an infinite power
4164 am.mantissa &= ~(uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
4165 if (am.power2 >= binary_format<T>::infinite_power()) {
4166 am.power2 = binary_format<T>::infinite_power();
4167 am.mantissa = 0;
4168 }
4169}
4170
4171template <typename callback>
4172fastfloat_really_inline FASTFLOAT_CONSTEXPR14 void

Callers 5

renderTrajectoryPathMethod · 0.50
drawCursorMethod · 0.50
formatTimeTickMethod · 0.50
renderGridMethod · 0.50
fractionalDecimalsFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected