Skip to content

Commit 170b4b5

Browse files
Rebase and narrow scope of casts in float_to_string
Patch llvm#74369 fixed one of the fixed in the previous commit. This rebases on top of that commit and also adjusts the casts in that file to better match.
1 parent 47091bc commit 170b4b5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

libc/src/__support/float_to_string.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,11 @@ LIBC_INLINE cpp::UInt<MID_INT_SIZE> get_table_negative(int exponent, size_t i) {
287287
if (block_shifts < static_cast<int>(ten_blocks)) {
288288
ten_blocks = ten_blocks - block_shifts;
289289
five_blocks = block_shifts;
290-
shift_amount = shift_amount + (block_shifts * BLOCK_SIZE);
290+
shift_amount = shift_amount + static_cast<int>(block_shifts * BLOCK_SIZE);
291291
} else {
292292
ten_blocks = 0;
293293
five_blocks = i;
294-
shift_amount = static_cast<int>(shift_amount + (i * BLOCK_SIZE));
294+
shift_amount = shift_amount + static_cast<int>(i * BLOCK_SIZE);
295295
}
296296
}
297297

@@ -490,7 +490,7 @@ class FloatToString {
490490
val = POW10_SPLIT[POW10_OFFSET[idx] + block_index];
491491
#endif
492492
const uint32_t shift_amount =
493-
static_cast<uint32_t>(SHIFT_CONST + (IDX_SIZE * idx) - exponent);
493+
SHIFT_CONST + static_cast<uint32_t>(IDX_SIZE * idx) - exponent;
494494
const uint32_t digits =
495495
internal::mul_shift_mod_1e9(mantissa, val, (int32_t)(shift_amount));
496496
return digits;
@@ -551,7 +551,7 @@ class FloatToString {
551551
val = POW10_SPLIT_2[p];
552552
#endif
553553
const int32_t shift_amount =
554-
static_cast<int32_t>(SHIFT_CONST + (-exponent - IDX_SIZE * idx));
554+
SHIFT_CONST + (-exponent - static_cast<int32_t>(IDX_SIZE * idx));
555555
uint32_t digits =
556556
internal::mul_shift_mod_1e9(mantissa, val, shift_amount);
557557
return digits;

0 commit comments

Comments
 (0)