Write a C program that finds and prints the machine epsilon for the float and double data types. Also print the values ​​of __FLT_EPSILON__ and __DBL_EPSILON__ defined in float.h. Reminder – the phrase data type tells how the compiler “understands” the ones and zeros you are working with. This identifies whether you are working with integers, letters, real numbers, and so on. Another definition:Machine epsilon is the "distance" between the number 1 and its immediate right neighbor. We work in binary (decimal is in parentheses): 1 + 0,1   = 1,1                    (1 + 1/2 = 1,5) 1 + 0,01  = 1,01                (1 + 1/4 = 1,25) 1 + 0,001 = 1,001            (1 + 1/8 = 1,125) then, due to the limited accuracy of the computer at a certain number of decimal places, a situation arises where 1 + 0.0…001 = 1 (instead of the correct 1.0…001). Then the previous number 0.0…01 is called the machine epsilon . It is obvious that its value may be different on different computers. However, the machine epsilon is not the smallest number in a given representation. Tip 1:  To find machine epsilon, start by dividing the number by one. However, you don't divide by ten, but by two, because we're working in the binary system! Tip 2:  Compare the result with the constants FLT_EPSILON and DBL_EPSILON, (or __FLT_EPSILON__ and __DBL_EPSILON__) defined in float.h.If the calculated values ​​do not suit you, try turning off all optimizations. If possible, try the program on a platform other than Win32/Intel.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter7: User-defined Simple Data Types, Namespaces, And The String Type
Section: Chapter Questions
Problem 1TF
icon
Related questions
Question

Write a C program that finds and prints the machine epsilon for the float and double data types. Also print the values ​​of __FLT_EPSILON__ and __DBL_EPSILON__ defined in float.h. Reminder – the phrase data type tells how the compiler “understands” the ones and zeros you are working with. This identifies whether you are working with integers, letters, real numbers, and so on.

Another definition:
Machine epsilon is the "distance" between the number 1 and its immediate right neighbor.

We work in binary (decimal is in parentheses):

1 + 0,1   = 1,1                    (1 + 1/2 = 1,5)

1 + 0,01  = 1,01                (1 + 1/4 = 1,25)

1 + 0,001 = 1,001            (1 + 1/8 = 1,125)

then, due to the limited accuracy of the computer at a certain number of decimal places, a situation arises where 1 + 0.0…001 = 1 (instead of the correct 1.0…001). Then the previous number 0.0…01 is called the machine epsilon . It is obvious that its value may be different on different computers. However, the machine epsilon is not the smallest number in a given representation.

Tip 1:  To find machine epsilon, start by dividing the number by one. However, you don't divide by ten, but by two, because we're working in the binary system!

Tip 2:  Compare the result with the constants FLT_EPSILON and DBL_EPSILON, (or __FLT_EPSILON__ and __DBL_EPSILON__) defined in float.h.
If the calculated values ​​do not suit you, try turning off all optimizations. If possible, try the program on a platform other than Win32/Intel.

AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage