This is a follow up post for this question this question.
- I've decided to ditch my previous approach using
Math.ulp()
and adopt Tim Leek's suggestion: comparing ratios comparing ratios. In my updated code, I calculate both ratios and ensure that their difference from 1 is within the tolerance. - The flexibility of the class is still kept in mind; getters and setters have been added to compliment the
private static
tolerance values. - The constructor is made
private
to prevent instantiation (which I simply forgot about in the previous version).
Basically, I fix my code when someone manages to break it. Tom Leek opened my eyes. Spotted's answer Spotted's answer was nice too, but it's too bad that it must be done in a slightly different way to ensure compilation. It was a nice feeling when I saw my code pass in the cases mentioned by Tom Leek.
This is a follow up post for this question.
- I've decided to ditch my previous approach using
Math.ulp()
and adopt Tim Leek's suggestion: comparing ratios. In my updated code, I calculate both ratios and ensure that their difference from 1 is within the tolerance. - The flexibility of the class is still kept in mind; getters and setters have been added to compliment the
private static
tolerance values. - The constructor is made
private
to prevent instantiation (which I simply forgot about in the previous version).
Basically, I fix my code when someone manages to break it. Tom Leek opened my eyes. Spotted's answer was nice too, but it's too bad that it must be done in a slightly different way to ensure compilation. It was a nice feeling when I saw my code pass in the cases mentioned by Tom Leek.
This is a follow up post for this question.
- I've decided to ditch my previous approach using
Math.ulp()
and adopt Tim Leek's suggestion: comparing ratios. In my updated code, I calculate both ratios and ensure that their difference from 1 is within the tolerance. - The flexibility of the class is still kept in mind; getters and setters have been added to compliment the
private static
tolerance values. - The constructor is made
private
to prevent instantiation (which I simply forgot about in the previous version).
Basically, I fix my code when someone manages to break it. Tom Leek opened my eyes. Spotted's answer was nice too, but it's too bad that it must be done in a slightly different way to ensure compilation. It was a nice feeling when I saw my code pass in the cases mentioned by Tom Leek.
This is a follow up follow up post for this question.
This is a follow up post for this question.
This is a follow up post for this question.
Better Floating Pointpoint equality in Java - follow-up
This is a follow up post for this question .
This is a follow up post for this question .
- I've decided to ditch my previous approach using
Math.ulp()
and adopt Tim Leek's suggestion: comparing ratios. In my updated code, I calculate both ratios and ensure that their difference from 1 is within the tolerance. - The flexibility of the class is still kept in mind; Gettersgetters and setters have been added to compliment the
private static
tolerance values. - The constructor is made
private
to prevent instantiation (which I simply forgot about in the previous version).
Basically, I fix my code when someone manages to break it. Tom Leek opened my eyes. Spotted's answer was nice too, but it's too bad that it must be done in a slightly different way to ensure compilation. It was a nice feeling when I saw my code pass in the cases mentioned myby Tom Leek.
The above code runs without resulting in any assertion errors. (Yipee!!)
The above code runs without resulting in any assertion errors. My request is simple: try breaking this one as well. ;-)
Better Floating Point equality in Java
This is a follow up post for this question .
- I've decided to ditch my previous approach using
Math.ulp()
and adopt Tim Leek's suggestion: comparing ratios. In my updated code, I calculate both ratios and ensure that their difference from 1 is within the tolerance. - The flexibility of the class is still kept in mind; Getters and setters have been added to compliment the
private static
tolerance values. - The constructor is made
private
to prevent instantiation (which I simply forgot about in the previous version).
Basically, I fix my code when someone manages to break it. Tom Leek opened my eyes. Spotted's answer was nice too, but it's too bad that it must be done in a slightly different way to ensure compilation. It was a nice feeling when I saw my code pass in the cases mentioned my Tom Leek.
The above code runs without resulting in any assertion errors. (Yipee!!)
My request is simple: try breaking this one as well ;-)
Floating point equality in Java - follow-up
This is a follow up post for this question .
- I've decided to ditch my previous approach using
Math.ulp()
and adopt Tim Leek's suggestion: comparing ratios. In my updated code, I calculate both ratios and ensure that their difference from 1 is within the tolerance. - The flexibility of the class is still kept in mind; getters and setters have been added to compliment the
private static
tolerance values. - The constructor is made
private
to prevent instantiation (which I simply forgot about in the previous version).
Basically, I fix my code when someone manages to break it. Tom Leek opened my eyes. Spotted's answer was nice too, but it's too bad that it must be done in a slightly different way to ensure compilation. It was a nice feeling when I saw my code pass in the cases mentioned by Tom Leek.
The above code runs without resulting in any assertion errors. My request is simple: try breaking this one as well. ;-)