Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Generic / String / String.cpp
diff options
context:
space:
mode:
1 files changed, 2 insertions, 12 deletions
-rw-r--r--src/Generic/String/String.cpp14
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("") {}