Finding minimum normalized positive number

  • Thread starter Thread starter ~electric~
  • Start date Start date
  • Tags Tags
    Minimum Positive
Click For Summary
SUMMARY

The discussion focuses on writing a C program to find the minimum normalized positive number representable in a computer, specifically the value 2.2250738585072014e-308. The initial approach involved halving a variable named Epsilon until the smallest value meeting the condition was found. However, confusion arose regarding the use of float versus double precision. The solution provided emphasizes changing Epsilon to a double precision variable and using the correct type casting to ensure accurate results. Additionally, referencing the limits.h file for DBL_MIN and FLT_MIN is recommended for further clarity.

PREREQUISITES
  • Understanding of C programming language
  • Knowledge of floating-point precision and representation
  • Familiarity with data types: float and double
  • Access to limits.h for floating-point limits
NEXT STEPS
  • Learn about C data types and their precision differences
  • Research the IEEE 754 standard for floating-point arithmetic
  • Explore the limits.h header file for floating-point limits in C
  • Investigate techniques for calculating machine precision in C
USEFUL FOR

C programmers, computer scientists, and anyone interested in understanding floating-point representation and precision in programming.

~electric~
Messages
14
Reaction score
0
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.
 
Technology news on Phys.org
I'm confused. You've casted Epsilon to a float (single precision), yet the value you shows is the POSIX value for min double precision numbers. Make Epsilon a double precision variable, and change the cast (float) to (double) - for starters.

Also, look in the limits.h file (unless you are on windows) for DBL_MIN and FLT_MIN.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 28 ·
Replies
28
Views
5K
  • · Replies 17 ·
Replies
17
Views
3K
Replies
1
Views
3K
  • · Replies 30 ·
2
Replies
30
Views
7K
  • · Replies 22 ·
Replies
22
Views
5K
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K