0

enter image description here

Is it a bug, or there's some official document that says, that this was supposed to happen?? Because my C program worked very well.

  • Related (specifically about C): https://stackoverflow.com/q/12240228/4722345 – JBallin Feb 12 '23 at 20:55
  • I thought that was integer, division, but yes it answers. Thank you – Cyber World Feb 12 '23 at 20:57
  • [Please don't post screenshots of text](https://meta.stackoverflow.com/a/285557/354577). They can't be searched or copied, or even consumed by users of adaptive technologies like screen readers. Instead, paste the code as text directly into your question, then select it and click the code block button. – ChrisGPT was on strike Feb 12 '23 at 21:53

2 Answers2

1

In the Python line, you're using floor division, which rounds down. In C, division truncates the decimal values.

HiPeople
  • 103
  • 4
1
>>> -10/8   # standard division
-1.25
>>> -10//8  # floor division
-2

The / and // behave differently as you noticed.

With the floor division your result gets rounded to the next smallest number which is in negative numbers -2.

53RT
  • 649
  • 3
  • 20