JavaHamcrest
JavaHamcrest copied to clipboard
Add FloatCloseTo matcher and refactor *CloseTo matchers
Updated pull request #226.
Changes:
- Create base class
BaseCloseTofor all closeTo matchers - Add
FloatCloseTomatcher - Rename
IsCloseTomatcher toDoubleCloseTo - Change error message for excluding errors in additional floating calculations (May user catch this error even with doubles?)
PS. Example of error with additional floating calculations:
public static void main(String[] args) {
var f = Math.abs(1.0f - 0.1f);
System.out.println(f + " " + (f - 0.5f));
var d = Math.abs(1.0d - 0.1d);
System.out.println(d + " " + (d - 0.5d));
}
After run:
0.9 0.39999998
0.9 0.4