kuangliu:

Seemed .long() has a numeric precision problem 



No – that’s just how floating-point arithmetic works. print(b) rounds to 4 decimal points. If you print out b.item() you’ll see: 0.999999046325683 which rounds down to zero.
See https://www.exploringbinary.com/why-0-point-1-does-not-exist-in-floating-point/ 1 for more explanation.