Round a Floating Point Number Down to the Nearest Integer?

前端 未结 12 1460
悲哀的现实
悲哀的现实 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:23

    To get floating point result simply use:

    round(x-0.5)
    

    It works for negative numbers as well.

提交回复
热议问题