0

[x] is the whole part (floor) of x
{x} is the fractional (decimal) part of x

Ex:
[5,76] = 5;     [12/13] = 0;       [e] = 2;
{9/4}=0,25;     {69/2}=0,5;        {4}=0;

Are those functions defined for negative numbers and how?

gfsdfgsfgd
  • 11
  • 1
  • The floor of a number $x$ is the greatest integer which is less than or equal to $x$. We have for instance $\lfloor 2.7\rfloor = 2$ as $2$ is the greatest integer less than or equal to $2.7$. This definition is perfectly sound as it pertains to negative numbers as well... $\lfloor -3.9\rfloor = -4$ as $-4$ is the largest integer which is less than or equal to $-3.9$. – JMoravitz Apr 07 '22 at 18:21
  • 1
    Now... as for fractional parts, the fractional part of a number $x$ is usually defined as $x-\lfloor x\rfloor$. For positive numbers, the result is as one would expect... just chop off everything that occurs prior to the decimal point... for instance ${3.77}=0.77$. For negative numbers, recall how floor is defined and acts. We would have ${-6.25} = 0.75$ noting that $-6.25 = (-7)+0.75$. Do note that certain programming languages may do things differently and one should always confirm the behavior of such things according to the appropriate context. – JMoravitz Apr 07 '22 at 18:24
  • Note that the fractional part of a negative number is not universally defined. Some people define $x = \lfloor x\rfloor + {x}$ for $x<0$ and others define $x = \lceil x \rceil + {x}$ for $x < 0$. This leads to two different definitions, so we have to keep that in mind. See here for instance – Brian Moehring Apr 07 '22 at 18:25

1 Answers1

3

$[x]$ is defined as the nearest integer less than $x$.

For example,

  • $[4.78] = 4$.
  • $[-4.78] = -5$.

$\{x\}$ is defined as

$$\{x\} = x - [x].$$

For example,

  • $\{4.78\} = 4.78 - [4.78] = 4.78-4 = 0.78$.
  • $\{-4.78\} = -4.78 - [-4.78] = -4.78-(-5) = 0.22$.
Eugene
  • 1,738