projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6638455
)
Util: Fix issue where t=0 randomly shows up as +0 or -0
author
Soeren Apel
<soeren@apelpie.net>
Wed, 12 Aug 2015 15:34:09 +0000
(17:34 +0200)
committer
Uwe Hermann
<uwe@hermann-uwe.de>
Sun, 16 Aug 2015 16:54:18 +0000
(18:54 +0200)
pv/util.cpp
patch
|
blob
|
history
diff --git
a/pv/util.cpp
b/pv/util.cpp
index 6772b040defddb3660e4cb46d52019a737f1456e..133317e0b9d98b0b074d688f9919da3ce5f65df0 100644
(file)
--- a/
pv/util.cpp
+++ b/
pv/util.cpp
@@
-39,6
+39,7
@@
static const QString SIPrefixes[17] =
"T", "P", "E", "Z", "Y"};
const int FirstSIPrefix = 8;
const int FirstSIPrefixPower = -(FirstSIPrefix * 3);
"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)
QString format_si_value(double v, QString unit, int prefix,
unsigned int precision, bool sign)
@@
-158,6
+159,10
@@
static QString format_time_with_si(double t, QString unit, int prefix,
QString format_time(double t, int prefix, TimeUnit unit,
unsigned int precision, double step_size, bool sign)
{
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);
// 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);