From 83a4f8032fbdad2ea35ef101dfb14433f672b6d9 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 29 May 2022 13:04:41 +0300 Subject: Autocommit at 29.05.2022 @ 13:04 --- src/Generic/String/String.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/Generic/String/String.cpp') diff --git a/src/Generic/String/String.cpp b/src/Generic/String/String.cpp index d37e9b7..d9cc235 100644 --- a/src/Generic/String/String.cpp +++ b/src/Generic/String/String.cpp @@ -81,18 +81,8 @@ String& String::operator+=(unsigned number) { * Converts the number to a C-style string and then uses += to append it. */ String& String::operator+=(double number) { - unsigned tempLen = 0; - for (unsigned tmp = number; tmp > 0 || tempLen == 0; tmp /= 10) - tempLen++; - - char* tmp = new char[tempLen + 1]; - tmp[tempLen] = '\0'; - for (unsigned i = tempLen - 1; i < tempLen; i--, number /= 10) - tmp[i] = number % 10 + '0'; - - *this += tmp; - delete[] tmp; - return *this; + if (number < 0) *this += "-"; + return ((*this += (unsigned)number) += ".") += (unsigned)((number - (unsigned)number) * DOUBLE_PRECISION); } String::String() : String("") {} -- cgit v1.3.1-23-gd82d