Skip to main content
Logo image

Section 5.1 Digital Representation of Integers

Previously, we learned that in C, the computer thinks that 5/2=2. But why is this the case?
More specifically, we noticed the following division behaviors in C:
  • 5/2 = 2
    
  • 5.0/2 = 2.5
    
  • 5/2.0 = 2.5
    
  • 5.0/2.0 = 2.5
    

Activity 5.1.

Why is this behavior with division happening?
Please enter your answer into the box below.

Activity 5.2.

Why is this behavior with division happening?
Please enter your answer into the box below.
This will make much more sense to you once you understand how numbers are actually stored inside the computer.