I want to perform boundary value analysis on a program which takes 3 float variables as input and returns the largest out of them. There's no range specified hence I impose the range to be the one implied by the no. of bytes used to store float variables, in my case 4 bytes. Hence, my float range becomes -3.4+38 to +3.4+38
Problem is: in boundary value u check these points: say your range is : 1<= x <= 10, the points which you need to check are : {1, 2, 9, 10}
In my float example I can't come to understand which value comes just above -3.4+38 and which value falls just below +3.4e+38. someone help here.I don't get this float representation.
Let us assume that you are programming in C. Any other high-level language should map the concepts to similar notations.
The
float
value just above-3.4e+38f
isnextafterf(-3.4e+38f, 0)
. Thefloat
value just below3.4e+38f
isnextafterf(3.4e+38f, 0)
, and you can also compute it as the opposite of the previous one if you find that clearer.You can also obtain these constants by typing
-3.399999749e+38
and3.399999749e+38
respectively if you do not have a functionnextafterf
.Note that
3.4e+38f
is not the largestfloat
, only a rough approximation of it (and 3.4+38, or approximately 41.4, even less so).