: I'm using solr 4.0 and I'm using an atomic update to increment a tdouble 
: 3 times with the same value (99.4). The third time it is incremented the 
: values comes out to 298.20000000000005. Has anyone seen this error or 
: how to fix it? Maybe I should use the regular double instead of a 
: tdouble?

this is the general nature of floating point math in most langauges -- 
including java...

http://stackoverflow.com/questions/322749/retain-precision-with-doubles-in-java
http://www.ibm.com/developerworks/java/library/j-math2/index.html

: 1 x "weight_td":{"set":0.0}
: 3 x "weight_td":{"inc":99.4}

public final class Temp {
    public static double val = 0.0D;

    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {
            System.out.println(i + ") " + val);
            val += 99.4;
        }
    }
}
// OUTPUT...
// 0) 0.0
// 1) 99.4
// 2) 198.8
// 3) 298.20000000000005
// 4) 397.6





-Hoss

Reply via email to