Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can someone explain the Math.ulp(double) method?

Tags:

java

math

I haven't been able to find any information online that doesn't already assume I know things. I wonder if anyone knows any good resources that I can look into to help me wrap my head around what this function does exactly?

From what I gather, and I'm pretty certain this is wrong or at least not fully right, is that given a floating point, it determines the distance between itself and some number next in a sequence? There appears to be something to do with how number are represented bitwise, but the sources I've read never explicitly said anything about that.

like image 340
Julian Avatar asked Dec 19 '22 03:12

Julian


1 Answers

http://matlabgeeks.com/tips-tutorials/floating-point-comparisons-in-matlab/

illustrated it rather well:

float2bin(A)

//ans = 0011111110111001100110011001100110011001100110011001100110100000

float2bin(B)

//ans = 0011111110111001100110011001100110011001100110011001100110011010

You can see the difference in precision at a binary level in this example. A and B differ by 6 ulps (units in the last place)

like image 73
Bobby Avatar answered Jan 13 '23 14:01

Bobby