aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-08-13 13:11:45 +0200
committerThomas White <taw@physics.org>2014-08-13 13:11:45 +0200
commitf210d6eff87a8ab5260a6cedd2adda518c7e9de8 (patch)
treeb225d05809ae6543ba35defdc0048981e1c6f3d8 /src
parent790d9e2f31bf166ee9213fb553958eabfe37be30 (diff)
hdfsee: Handle non-integers in numbers view
This is really horrible, but better than just pretending everything is an integer.
Diffstat (limited to 'src')
-rw-r--r--src/dw-hdfsee.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c
index 0e199752..d300b9fe 100644
--- a/src/dw-hdfsee.c
+++ b/src/dw-hdfsee.c
@@ -1581,17 +1581,20 @@ static void numbers_update(DisplayWindow *dw)
val = dw->image->data[fs+ss*dw->image->width];
- if ( val > 0.0 ) {
- if ( log(val)/log(10.0) < 5 ) {
- snprintf(s, 31, "%.0f", val);
- } else {
- snprintf(s, 31, "HUGE");
- }
+ if ( (val > 0.0) && (log(val)/log(10.0) >= 5) ) {
+ snprintf(s, 31, "HUGE");
+ } else if ( (val < 0.0) && (log(-val)/log(10) >= 4) ) {
+ snprintf(s, 31, "-HUGE");
} else {
- if ( log(-val)/log(10) < 4 ) {
- snprintf(s, 31, "%.0f", val);
- } else {
- snprintf(s, 31, "-HUGE");
+ size_t l, i;
+ snprintf(s, 31, "%.4f", val);
+ l = strlen(s);
+ for ( i=l-1; i>0; i-- ) {
+ if ( s[i] == '0' ) s[i] = '\0';
+ if ( s[i] == '.' ) {
+ s[i] = '\0';
+ break;
+ }
}
}