468,484 Members | 1,649 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,484 developers. It's quick & easy.

Finding minimum normalized positive number

16
Hello,
I was asked to write a C program to find minimum normalized positive number that can be represented in my computer. I know that the value is 2.2250738585072014e-308.
I wrote the program to find the machine precision. Now i need to make some parameter changes to this program to find the min. number given above.
do
{
Epsilon = Epsilon/2.0 ; //Variable value is halved until the smallest
//value of 'e' is found while meeting the
//required condition
}
while ((float)((Epsilon+1.0))>1.0);

Epsilon = 2*Epsilon;

this gave me the machine precision. Any help would be appreciated.
thanks in advance.
Jan 21 '08 #1
1 2370
Expand|Select|Wrap|Line Numbers
  1. double Epsilon;
  2. double store;
  3.  
  4. int main(int argc, char *argv[]) {
  5.     Epsilon = 1;
  6.     do {
  7.         Epsilon /= 2; //Variable value is halved until the smallest
  8.         //value of 'e' is found while meeting the
  9.         //required condition
  10.         store = Epsilon/2;
  11.     } while (store != 0);//If the smallest, then Epsilon/2 == 0 as Epsilon/2 approches 0.
  12.  
  13.     cout << "The smallest normalized number is: " << Epsilon << endl;
  14.  
  15.     system("PAUSE");
  16.     return EXIT_SUCCESS;
  17. }
  18.  
As suggested in the reply to your topic at 'http://www.physicsforums.com/showthread.php?t=210044', you must cast Epsilon as a double rather than single -floating point number. This is because doubles can represent numbers smaller than floating-point numbers (see wikipedia, I say =D).

Epsilon approaches 0 when repeatedly divided, and indeed meets 0 at the lowest normalized number. The variable "store" is used to identify where this lowest point occurs without changing the value of Epsilon to 0. Interestingly, my computer produced a result ~ 4.94066 e-324 (or something like that), which implies either your produced limit is wrong, or I have incorrectly coded the solution, because a limit is a limit is a limit. I can't speculate as to why this might occur.
Feb 26 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

17 posts views Thread by Adam H. Peterson | last post: by
13 posts views Thread by Peter Ammon | last post: by
15 posts views Thread by cwsullivan | last post: by
4 posts views Thread by sathyashrayan | last post: by
19 posts views Thread by gk245 | last post: by
2 posts views Thread by Janelle.Dunlap | last post: by
5 posts views Thread by raybakk | last post: by
2 posts views Thread by Jameson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.