"T", "P", "E", "Z", "Y"};
const int FirstSIPrefix = 8;
const int FirstSIPrefixPower = -(FirstSIPrefix * 3);
+const double MinTimeDelta = 1e-15; // Anything below 1 fs can be considered zero
QString format_si_value(double v, QString unit, int prefix,
unsigned int precision, bool sign)
if (precision >= 0) {
ts << pad_number(seconds, use_padding ? 2 : 0);
- const double fraction = fabs(t - whole_seconds);
+ const double fraction = fabs(t) - whole_seconds;
if (precision > 0 && precision < 1000) {
QString fs = QString("%1").arg(fraction, -(2 + precision), 'f',
QString format_time(double t, int prefix, TimeUnit unit,
unsigned int precision, double step_size, bool sign)
{
+ // Make 0 appear as 0, not random +0 or -0
+ if (fabs(t) < MinTimeDelta)
+ return "0";
+
// If we have to use samples then we have no alternative formats
if (unit == Samples)
return format_time_with_si(t, "sa", prefix, precision, sign);