YCP Logo Lab 4: Floating-point imprecision

Floating-point imprecision

Test the claim that the number 0.1 (one tenth) cannot be represented exactly as a floating-point value.

You should write a program that uses the printf function to print the literal floating-point value 0.1 to a sufficent number of decimal places that you can see that it does not equal precisely 0.1.

Getting started

Start by downloading CS200_Lab4.zip and using the File->Import... menu option to import it into Visual Studio. Add your code to the source file DecimalPlaces.c.

You are done when you prove it is possible to print the literal value 0.1 and show that it does not equal 0.1.


As a literal, 0.1 is a value whose type is double.

Use the %f conversion specifier to print the value. Use the formatting option which specifies the number of digits of precision: e.g., to print two digits after the decimal place, you would use the conversion specifier


Note that you can specify more than 9 digits of precision.

Question: what is the smallest number of digits of precision you need to show that the value is not equal to 0.1?


When you are done, choose Tools->Submit to submit your completed lab to the server. You will need to enter your Marmoset username and password.