stoicflame / ofx4j

Apache License 2.0
75 stars 50 forks source link

Dont use BigDecimal constructor since it can lead to unpredictable results #43

Closed ekennedy247 closed 4 years ago

ekennedy247 commented 4 years ago

Per the java-doc:

     * The results of this constructor can be somewhat unpredictable.
     * One might assume that writing {@code new BigDecimal(0.1)} in
     * Java creates a {@code BigDecimal} which is exactly equal to
     * 0.1 (an unscaled value of 1, with a scale of 1), but it is
     * actually equal to
     * 0.1000000000000000055511151231257827021181583404541015625.
     * This is because 0.1 cannot be represented exactly as a
     * {@code double} (or, for that matter, as a binary fraction of
     * any finite length).  Thus, the value that is being passed
     * <i>in</i> to the constructor is not exactly equal to 0.1,
     * appearances notwithstanding.

Test results:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.329 s
[INFO] Finished at: 2020-02-05T16:24:35-05:00
[INFO] ------------------------------------------------------------------------
stoicflame commented 4 years ago

Version 1.22 released.