MCPcopy Create free account
hub / github.com/Qucs/qucs / StringNum

Method StringNum

qucs/misc.cpp:77–104  ·  view source on GitHub ↗

#########################################################################

Source from the content-addressed store, hash-verified

75
76// #########################################################################
77QString misc::StringNum(double num, char form, int Precision)
78{
79 int a = 0;
80 char *p, Buffer[512], Format[6] = "%.00g";
81
82 if(Precision < 0) {
83 Format[1] = form;
84 Format[2] = 0;
85 }
86 else {
87 Format[4] = form;
88 Format[2] += Precision / 10;
89 Format[3] += Precision % 10;
90 }
91 sprintf(Buffer, Format, num);
92 p = strchr(Buffer, 'e');
93 if(p) {
94 p++;
95 if(*(p++) == '+') { a = 1; } // remove '+' of exponent
96 if(*p == '0') { a++; p++; } // remove leading zeros of exponent
97 if(a > 0)
98 do {
99 *(p-a) = *p;
100 } while(*(p++) != 0); // override characters not needed
101 }
102
103 return QString(Buffer);
104}
105
106// #########################################################################
107QString misc::StringNiceNum(double num)

Callers

nothing calls this directly

Calls 1

QStringClass · 0.70

Tested by

no test coverage detected