mirror of https://gitlab.com/rnger/amath
Fixed truncation bug
This commit is contained in:
parent
a56173487f
commit
af7bf8a97a
|
@ -165,6 +165,24 @@ bool CharBuffer::Is(const char* string)
|
|||
return StrIsEqual(GetString(), string);
|
||||
}
|
||||
|
||||
bool CharBuffer::Contains(const char c)
|
||||
{
|
||||
char* i = buf;
|
||||
|
||||
if (i == NOMEM || buf == ptr)
|
||||
return false;
|
||||
|
||||
do
|
||||
{
|
||||
if (*i == c)
|
||||
return true;
|
||||
|
||||
i++;
|
||||
} while (i != ptr);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CharBuffer::Empty()
|
||||
{
|
||||
if (buf == NOMEM) {
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
* @brief Compare content of CharBuffer with string)
|
||||
*/
|
||||
bool Is(const char *string);
|
||||
bool Contains(const char c);
|
||||
|
||||
void Copy(CharBuffer *buf);
|
||||
void Append(const char *source);
|
||||
|
|
|
@ -444,11 +444,14 @@ const char* DecimalSystem::GetRealText(double value)
|
|||
PrintFloat64(out, size, roundedvalue, format, formatdigits, fractionpoint);
|
||||
buf->EnsureGrowth(size);
|
||||
buf->Append(out);
|
||||
while (buf->RemoveTrailing('0'))
|
||||
;
|
||||
buf->RemoveTrailing(fractionpoint);
|
||||
delete[] out;
|
||||
|
||||
if (fractionpoint != '\0' && buf->Contains(fractionpoint))
|
||||
{
|
||||
while (buf->RemoveTrailing('0'))
|
||||
;
|
||||
buf->RemoveTrailing(fractionpoint);
|
||||
}
|
||||
|
||||
delete[] out;
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue