-1

So I am trying to learn how to divide fractions. I am confused why dividing variables gives the correct result, and dividing the numbers themselves gives an incorrect result. I have tried to searching on here and couldn't find anything relevant. Here is an image to show why I am talking about. enter image description here

pewpew
  • 700
  • 2
  • 9
  • 32

1 Answers1

3

The expression 1 / 3 is an integer expression. You divide two int values. That leads to truncation.

Try e.g. 1.0 / 3.0 instead.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621