altoslib: Start integrated value at 0 by default
authorKeith Packard <keithp@keithp.com>
Tue, 3 Sep 2013 23:41:12 +0000 (17:41 -0600)
committerKeith Packard <keithp@keithp.com>
Tue, 3 Sep 2013 23:41:12 +0000 (17:41 -0600)
Check for MISSING and start at zero in that case

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosState.java

index 726c3041f4587edc5c3533a701e3d0a242f2f57d..e874a498b0ed066aa02387afcab22fd54fe88b92 100644 (file)
@@ -150,8 +150,12 @@ public class AltosState implements Cloneable {
                void set_integral(AltosValue in) {
                        double  change = in.integrate();
 
                void set_integral(AltosValue in) {
                        double  change = in.integrate();
 
-                       if (change != AltosRecord.MISSING)
-                               set(prev_value + change, in.time());
+                       if (change != AltosRecord.MISSING) {
+                               double  prev = prev_value;
+                               if (prev == AltosRecord.MISSING)
+                                       prev = 0;
+                               set(prev + change, in.time());
+                       }
                }
 
                void copy(AltosValue old) {
                }
 
                void copy(AltosValue old) {