Apache Math 3.4 (and 3.3), java 1.8.0_25
import org.apache.commons.math3.distribution.ChiSquaredDistribution;
ChiSquaredDistribution chisq = new ChiSquaredDistribution(23)
System.out.println(1.0 - chisq.cumulativeProbability(130) // 1.1102230246251565E-16
System.out.println(1.0 - chisq.cumulativeProbability(131) // 0.0
Why does Apache Math return 0.0 in the second call? Some stat libraries (Excel, but not R) do return values that are much smaller than 1E-16 for the tail probabilities.
Additional Edit: In the comments below, Robert provides a direct way of calculating chi square tail probabilities using another function from Apache math library (regularizedGammaQ) that does not have this precision problem.
Note that the smallest value which can be subtracted from 1.0 to yield something less than 1.0 is approximately 1e-16; you can verify this directly. Maybe you should print out chisq.cumulativeProbability(131) itself. I don't know if it's correct but in any case let's not confuse the issue by subtracting it from 1.0.