2.9999999999999999 >> .5?

后端 未结 10 1859
逝去的感伤
逝去的感伤 2021-02-07 15:32

I heard that you could right-shift a number by .5 instead of using Math.floor(). I decided to check its limits to make sure that it was a suitable replacement, so I checked the

10条回答
  •  悲&欢浪女
    2021-02-07 16:22

    If you wanna go deeper, read "What Every Computer Scientist Should Know About Floating-Point Arithmetic": http://docs.sun.com/source/806-3568/ncg_goldberg.html

提交回复
热议问题