Is it correct that $-\lfloor0.5\rfloor \ne \lfloor(-0.5)\rfloor$?

135 Views Asked by At

As I understand floor functions:

$\lfloor (-0.5)\rfloor = -1$

while

$-\lfloor(0.5)\rfloor = -0 = 0$

Am I understanding floor functions correctly?

2

There are 2 best solutions below

0
On BEST ANSWER

Yes, you are correct. Wikipedia and Mathworld agree (you can look at the graphs there). Be careful, though: There's a small chance that some programming language will have floor defined incorrectly for negative inputs.

0
On

In general. For positive non integer $x $, If $0 < n < x <n+1$ then $-n-1 <x <-n $.

So....

$[x]=n $ while $[-x]=-n-1=-[x]-1$

But if $x $ is an integer then $[x]=[n]=n=$ and $[-x]=[-n]=-n=-x $.

It seems a little weird but it all makes sense.