MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / format_time

Method format_time

DSView/pv/view/ruler.cpp:145–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145QString Ruler::format_time(double t, int prefix,
146 unsigned int precision)
147{
148 const double multiplier = pow(10.0, -prefix * 3 - FirstSIPrefixPower + 6.0);
149
150 /*
151 QString s;
152 QTextStream ts(&s);
153 ts.setRealNumberPrecision(precision);
154 ts << fixed << forcesign << (t * multiplier) / 1000000.0 <<
155 SIPrefixes[prefix] << "s";
156 return s;
157 */
158
159 char buffer[50];
160 char format[15];
161 QString units = SIPrefixes[prefix] + "s";
162 double v = (t * multiplier) / 1000000.0;
163 buffer[0] = v >= 0 ? '+' : '-';
164 sprintf(format, "%%.%df", (int)precision);
165 sprintf(buffer + 1, format, v);
166 strcat(buffer + 1, units.toUtf8().data());
167 return QString(buffer);
168}
169
170QString Ruler::format_time(double t)
171{

Callers

nothing calls this directly

Calls 1

dataMethod · 0.45

Tested by

no test coverage detected