Treating Integers as Doubles for Certain Operations?

Revision en1, by minimario, 2017-12-31 21:36:40

Hello again :)

Recently I was solving problem with integers a[i] which involved two operations a[i] //= 2 and a[i] -= 1. And I read that it is equivalent that when we are performing these operations, to consider a[i] as a double, transforming a[i] //= 2 to a[i] / 2, and then at the end taking the floor.

This is a little obvious, but nevertheless very surprising to me. Can someone prove it?

Tags smile, sweet, service, surprise

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English minimario 2017-12-31 21:36:40 451 Initial revision (published)