Round a Floating Point Number Down to the Nearest Integer?

前端 未结 12 1435
悲哀的现实
悲哀的现实 2020-12-02 13:45

As the title suggests, I want to take a floating point number and round it down to the nearest integer. However, if it\'s not a whole, I ALWAYS want to round down the variab

12条回答
  •  自闭症患者
    2020-12-02 14:27

    Just make round(x-0.5) this will always return the next rounded down Integer value of your Float. You can also easily round up by do round(x+0.5)

提交回复
热议问题