Skip to content

Commit da36ac1

Browse files
authored
Merge pull request #64 from RuntimeTools/ftoa
Create float-to-ascii function ftoa & use for floats, doubles
2 parents 7b8cee9 + 1447805 commit da36ac1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/ibmras/common/common.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ std::string itoa(T t) {
3333
#endif
3434
}
3535

36+
template <class T>
37+
std::string ftoa(T t) {
38+
#ifdef _WINDOWS
39+
return std::to_string(static_cast<long double>(t));
40+
#else
41+
std::stringstream s;
42+
s << t;
43+
return s.str();
44+
#endif
45+
}
46+
3647
}
3748
}
3849

src/ibmras/common/data/json/JSON.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class JSONStat {
3535
public:
3636
JSONStat(const char* name) { this->name = name; value = NULL; }
3737
void setValue(char* value) { this->value = value;}
38-
void setValue(double value) { this->value = ibmras::common::itoa(value); };
38+
void setValue(double value) { this->value = ibmras::common::ftoa(value); };
3939
const char* getName();
4040
char* getValue();
4141
private:

0 commit comments

Comments
 (0)