Skip to content

Commit

Permalink
fix: issues with numbers between 0 and -1
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyV99 authored and connorjclark committed Jan 1, 2024
1 parent e9ab158 commit 1b44e3b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/base/util.cpp
Expand Up @@ -796,7 +796,7 @@ namespace util
if(val % 10000)
{
char buf[16] = {0};
sprintf(buf, "%d.%04d", val/10000, abs(val%10000));
strcpy(buf, zslongToFix(val).str().c_str());
for(auto q = strlen(buf)-1; buf[q] == '0'; --q)
{
//Kill trailing zeroes
Expand Down
2 changes: 1 addition & 1 deletion src/base/zfix.h
Expand Up @@ -214,7 +214,7 @@ class zfix

std::string str() const
{
return fmt::format("{}.{:04}",val/10000,abs(val%10000));
return fmt::format("{}{}.{:04}",val < 0 ? "-" : "",abs(val/10000),abs(val%10000));
}
public:

Expand Down
2 changes: 1 addition & 1 deletion src/gui/text_field.cpp
Expand Up @@ -242,7 +242,7 @@ void TextField::setVal(int32_t val)
sprintf(buf, "%d", startVal/10000);
else
{
sprintf(buf, "%d.%04d", startVal/10000, startVal%10000);
strcpy(buf, zslongToFix(startVal).str().c_str());
for(auto q = strlen(buf)-1; buf[q] == '0'; --q)
buf[q] = 0;
}
Expand Down

0 comments on commit 1b44e3b

Please sign in to comment.