19816 {
19817 using UNSIGNED = typename MakeUnsigned<SIGNED>::type;
19818 char *end = dst + len;
19819 if (value < 0) {
19820 value = -value;
19821 *dst = '-';
19822 }
19823 if (scale == 0) {
19824 NumericHelper::FormatUnsigned<UNSIGNED>(UnsafeNumericCast<UNSIGNED>(value), end);
19825 return;
19826 }
19827
19828
19829
19830 auto minor =
19831 UnsafeNumericCast<UNSIGNED>(value) % UnsafeNumericCast<UNSIGNED>(NumericHelper::POWERS_OF_TEN[scale]);
19832 auto major =
19833 UnsafeNumericCast<UNSIGNED>(value) / UnsafeNumericCast<UNSIGNED>(NumericHelper::POWERS_OF_TEN[scale]);
19834
19835 dst = NumericHelper::FormatUnsigned<UNSIGNED>(UnsafeNumericCast<UNSIGNED>(minor), end);
19836
19837 while (dst > (end - scale)) {
19838 *--dst = '0';
19839 }
19840 *--dst = '.';
19841
19842 D_ASSERT(width > scale || major == 0);
19843 if (width > scale) {
19844
19845 dst = NumericHelper::FormatUnsigned<UNSIGNED>(UnsafeNumericCast<UNSIGNED>(major), dst);
19846 }
19847 }