Talk:Floor and ceiling functions

Please better representation
See better ceil(x) at https://www.maplesoft.com/support/help/content/1939/image84.png as better "filled color" (red in this case). The line is also filled, like a bolded line. The addiction of the "empty point" representation of the line function needs to be bold. — Preceding unsigned comment added by Krauss (talk • contribs) 01:52, 7 June 2018 (UTC)


 * that would be great but I get access denied — Preceding unsigned comment added by Spitzak (talk • contribs) 23:12, 26 July 2022 (UTC)

Relation to directional rounding to integer
"Not quite rounding. See Floor and ceiling functions#Rounding."

Can someone please explain this? From what I can tell, rounding up to the nearest integer should be equivalent to ceiling, and similarly for rounding down equaling floor. The section referenced and the definitions of floor and ceiling are all incredibly technical and thus useless to anyone that has not gotten a degree in mathematics. --Bastian 51234 (talk) 23:27, 8 December 2019 (UTC)


 * Rounding is to the nearest integer—not necessarily to the nearest greater integer or nearest least integer. For example,
 * 1.4 rounded is 1,
 * the floor of 1.4 is 1,
 * the ceiling of 1.4 is 2.
 * 1.6 rounded is 2,
 * the floor of 1.6 is 1,
 * the ceiling of 1.6 is 2.
 * So the floor of a fraction is always down; the ceiling of a fraction is always up; rounding can be up or down depending upon whether the fraction is less than one half. —Anita5192 (talk) 00:09, 9 December 2019 (UTC)
 * I think I agree with on two points here: first, that the current first description is bizarrely technical, and second, that the floor and ceiling functions are particular rounding functions.  In particular, there are lots of rounding rules (see Rounding), and these two functions correspond to the rounding rules "round down" and "round up".  It would be good if the first sentence were less technical, and mentioning rounding somewhere in the lead would also be reasonable. --JBL (talk) 02:54, 10 December 2019 (UTC)
 * I also agree, in lay use the term "round down" and "round up" are equivalent floor and ceiling for positive numbers. Perhaps they are technically incorrect by using the word "round" but not returning the closest integer, but the terms are certainly used this way right or wrong.Spitzak (talk) 20:25, 10 December 2019 (UTC)
 * If a word/phrase is used to mean a certain thing, it takes that definition no matter the original meaning(see the words "awful" and "awesome" for example). On top of this, without the common definitions of the terms "round up" and "round down", the terms are,to my knowledge, meaningless in math. Because of these two things, I feel adding them would increase the average person's understanding without degrading the expert's understanding, especially if the clarification that this would be a simplified version of the definition. Bastian 51234 (talk) 05:54, 11 December 2019 (UTC)
 * If a word/phrase is used to mean a certain thing, it takes that definition no matter the original meaning(see the words "awful" and "awesome" for example). On top of this, without the common definitions of the terms "round up" and "round down", the terms are,to my knowledge, meaningless in math. Because of these two things, I feel adding them would increase the average person's understanding without degrading the expert's understanding, especially if the clarification that this would be a simplified version of the definition. Bastian 51234 (talk) 05:54, 11 December 2019 (UTC)

Real numbers or floating point numbers?
These functions are usually used with floating point numbers, an approximation of the real number system that has some important differences. Using them with real numbers gives some results that may be unexpected: floor(0.99999...) = 1 because 0.9 repeating is equal to 1. floor( max(0,1) ) = 0 using the range notation for all numbers between 0 and 1 exclusive. Also, Reference 1 cites this wikipedia page. It is a circular reference. Subcelestial (talk) 14:33, 4 November 2020 (UTC)


 * "These functions are usually used with floating point numbers" -- not true, they are also used in mathematics.
 * "floor(0.99999...) = 1 because 0.9 repeating is equal to 1." -- this is a fact about the rounding of 0.999..., not about the floor function; if floor(0.999...) returns 1, it means that the argument was actually 1.0.
 * "floor( max(0,1) ) = 0 using the range notation for all numbers between 0 and 1 exclusive." -- max(0,1) is not a standard notation for "all number between 0 and 1 exclusive".
 * So I don't think any changes are called for. --Macrakis (talk) 16:29, 4 November 2020 (UTC)
 * (edit conflict) I have removed this reference, and two others per WP:ELNO. Such web citing may be acceptable when there no reliably published references, but this is not the case here.
 * These functions are defined for real numbers, not only for floating point numbers, which all are rational numbers. Using approximations for computing may always lead to wrong results. For example, using floating-point,   does not normally results into 1 (some clever compilers may produce 1., by rearranging the order of operations). Here the floor function is specific because it is not continuous, which means that one cannot get a good approximation of the correct result by increasing the accuracy (size of the mantissa). D.Lazard (talk) 16:58, 4 November 2020 (UTC)

Integral part
In the recent edits, it is asserted that, as Legendre used "partie entière inférieure", the function that he denoted $$[x]$$ was the floor function. This is not convincing, because, I belive that he was interested only in positive values of $x$. So, it must be checked in Legendre's work whether he defined his function for negative $x$, and if he did, which was his definition. D.Lazard (talk) 20:43, 4 November 2020 (UTC)


 * I agree that this seems dubious without a very good citation, but I also think it was removed again (perhaps, by me)? --JBL (talk) 21:51, 4 November 2020 (UTC)
 * I saw that in a StackOverflow question when searching for whether [x] means floor or round-toward-zero, but no reliabla reference. I agree it is possible this is in error, and in fact [x] does not define the behavior for negative numbers. That would at least make it not conflict with the use of [x] for round-toward-zero which is used in the opening section (but I cannot find any references showing that use is common).Spitzak (talk) 22:24, 4 November 2020 (UTC)
 * The section currently reads:
 * "In words, this is the integer that has the largest absolute value less than or equal to the absolute value of $x$."
 * I agree with the IP who previously edited this, that it is ambiguous. For example, if x = –3.9, then |x| = 3.9, the largest integer less than or equal to |x| is 3, and the integer that has the largest absolute value less than or equal to the absolute value of x could be –3 or 3. — Anita5192 (talk) 15:33, 10 June 2021 (UTC)
 * I agree that the current wording is problematic, but I haven't come up with a concise alternative that is clearer. Maybe just drop the "in words" part? --Macrakis (talk) 16:47, 10 June 2021 (UTC)
 * I agree: drop the entire "in words" sentence. This edit seemed to correct the verbal explanation, but it was still difficult to follow. I think the simple definition is intuitively obvious and needs no further explanation. — Anita5192 (talk) 17:17, 10 June 2021 (UTC)
 * ✅ — Anita5192 (talk) 17:21, 10 June 2021 (UTC)
 * concur. Thx. Tricky - DVdm (talk) 19:04, 10 June 2021 (UTC)

Different definition of integer part in different countries
I think it would be useful to say somewhere that the definition of "integer part" given in the introduction is only valid in some countries. In France for example, this is equal to the floor function : see the french page "partie entière" of wikipedia.

This maybe answers the previous question ? --89.95.99.135 (talk) 18:33, 27 January 2021 (UTC)


 * I wonder if this is strictly an issue of language -- in which case it doesn't belong in the English WP -- or if different authors have different definitions, in which case we should mention that. --Macrakis (talk) 19:13, 16 June 2021 (UTC)
 * A quick literature search shows that definitions vary even in English, so I have mentioned that in the lead. Thanks for pointing that out. --Macrakis (talk) 21:27, 16 June 2021 (UTC)
 * I think a common name for the "integral part" function is "truncation". Certainly in computer science it is called that. May want to mention it. Also it sure looks like [x] does not mean this truncation function all the time, or even the majority of the time. Can't find any modern examples of it's use, and older texts treated it as floor.Spitzak (talk) 01:47, 17 June 2021 (UTC)
 * We had a section on truncation in this article, but there's actually a full article on it. I added a mention to the lead with a link and removed the unnecessary section. --Macrakis (talk) 14:23, 17 June 2021 (UTC)
 * Since this function and notation is very specific, is only mentioned briefly in the lead and the Notation section, and, as far as I know, rarely used, I think this should be moved in its entirety back into the Applications section.—Anita5192 (talk) 14:57, 17 June 2021 (UTC)
 * It is rare in mathematics, but common in programming. The full article on it should have any necessary details. --Macrakis (talk) 15:38, 17 June 2021 (UTC)
 * I have only seen the function described as "trunc(x)" or "int(x)". I would like to see some reference that anybody uses "[x]" for truncation. I am worried that this is a wikipedia-made-up "fact".Spitzak (talk) 17:51, 17 June 2021 (UTC)
 * The wording in the article doesn't say that [x] is used for truncation. It just says that "the operation of truncation generalizes this [sc. the integer part] to a specified number of digits". --Macrakis (talk) 19:45, 17 June 2021 (UTC)
 * The article says "the integer part is often represented as [x]". That is the statement I am unsure is true.Spitzak (talk) 20:57, 17 June 2021 (UTC)
 * Ah, I think I see what you're saying.
 * Both the name "integer part" and the notation [x] are, I think, ambiguous between the "floor" definition and the "truncate towards zero" definition. We can certainly rewrite the lead (with sources) to clarify all that. I don't have the time to do that right now, but I encourage you to do so yourself. --Macrakis (talk) 21:24, 17 June 2021 (UTC)
 * I am a bit baffled by the statement, "truncation to zero significant digits is the same as the integer part". In my mind, truncation of a value to zero significant digits is the same as introducing complete ambiguity in its magnitude.  I was tempted to change the text to "truncation to zero fractional digits is the same as the integer part," but that seems like such a fundamental statement that there must be some sort of unstated axiom in play -- whatever the case, that should be either rewritten as I proposed or somebody should have some sort of explanation or reference to what is really meant by a number with no significant digits.  — Preceding unsigned comment added by Dodecagon12 (talk • contribs) 20:23, 28 January 2022 (UTC)

"Greatest integer" listed at Redirects for discussion
An editor has identified a potential problem with the redirect Greatest integer and has thus listed it for discussion. This discussion will occur at Redirects for discussion/Log/2022 May 19 until a consensus is reached, and readers of this page are welcome to contribute to the discussion. D.Lazard (talk) 10:59, 19 May 2022 (UTC)

Definition of "integral part"
The article defines $[·]$ such that $[&minus;2.4] = &minus;2$, that is, as truncation towards zero. Some texts define the integral part of a number as "the part to the left of the decimal point". It is not clear, though, that the authors meant this to be applicable to negative real numbers. More recent sources define "integral part" as equivalent (or even explicitly as equal) to the floor function. The statement in the latter source that $[&minus;2.5] = &minus;3$ clearly contradicts the present definition in our article. --Lambiam 06:19, 23 May 2022 (UTC)
 * I very much suspect the idea that $[x]]|undefined$ means round-towards-zero and not floor is a made-up "fact" by wikipedia.Spitzak (talk) 17:18, 23 May 2022 (UTC)
 * I concur. The standard convention in mathematics is that $$[x]$$ and $$\lfloor x\rfloor$$ denote the same thing (unless $$[x]$$ means something completely different, such as the Iverson bracket).—Emil J. 11:33, 20 December 2022 (UTC)

Add history section
Apparently this notation (and names) was invented by the APL programming language designers in the 1960s. To do: Find a reliable source. Previous (and different) notations go back to Gauss. — Preceding unsigned comment added by 79.147.146.38 (talk)

Smallest
I'm concerned that at least some people think -1 is "smaller" than -2, and the use of the word "smallest" in the opening paragraphs is incorrect. I tried changing it to "lowest" but that got reverted. Any opinions on this? Spitzak (talk) 19:48, 6 December 2023 (UTC)


 * Both "smaller" and "lower" involve an implicit agreement between reader and author about how bigness (whether in the language of size or height) works for negative numbers. We could make explicit that the order relation in question is the usual total order on the real numbers, but I don't believe this will help the (in my estimation, very small) percentage of people who believe both that -1 is smaller than -2 and that -2 is lower than -1.  But, I would also be happy to hear the views of other editors.  --JBL (talk) 19:55, 6 December 2023 (UTC)

Possible Problem in "Equivalences" Section
The "Equivalences" section currently states that the following inequalities are always true:

$$\begin{align} \lfloor x \rfloor + \lfloor y \rfloor &\leq \lfloor x + y \rfloor \leq \lfloor x \rfloor + \lfloor y \rfloor + 1,\\[3mu] \lceil x \rceil + \lceil y \rceil -1 &\leq \lceil x + y \rceil \leq \lceil x \rceil + \lceil y \rceil. \end{align}$$

One of the two inequalities in each of these two "chains" must be strict, otherwise we would end up with the following contradictions:

$$\begin{align} \lfloor x \rfloor + \lfloor y \rfloor &= \lfloor x \rfloor + \lfloor y \rfloor + 1,\\[3mu] \lceil x \rceil + \lceil y \rceil -1 &= \lceil x \rceil + \lceil y \rceil. \end{align}$$

Either relation in each "chain" can be an equality. Let's examine the floor case.

Since $$ \lfloor x \rfloor \leq x $$ and $$ \lfloor x \rfloor \in \mathbb{Z} $$, the first inequality need not be strict:

$$ \lfloor x \rfloor + \lfloor y \rfloor = \lfloor \lfloor x \rfloor + \lfloor y \rfloor \rfloor \leq \lfloor x + y \rfloor. $$

Noting that since $$ x = \lfloor x \rfloor + \{x\} $$, and observing that $$ 0 \leq \{x\} < 1 $$ implies $$ 0 \leq \{x\} + \{y\} < 2 $$, the second inequality need not be strict:

$$ \lfloor x + y \rfloor = \lfloor \lfloor x \rfloor + \{x\} + \lfloor y \rfloor + \{y\} \rfloor = \lfloor x \rfloor + \lfloor y \rfloor + \lfloor \{x\} + \{y\} \rfloor \leq \lfloor x \rfloor + \lfloor y \rfloor + 1. $$

So I think it would make sense to update the article's text to clarify that while each inequality need not be strict, they can't simultaneously be equal. That is, for any given $$x$$ and $$y$$, one or the other must be strict.

I'm not sure how to best word this, though. Ilikefood (talk) 18:27, 15 June 2024 (UTC)


 * Maybe put a footnote? This doesn't seem that important to belabor. –jacobolus (t) 18:47, 15 June 2024 (UTC)
 * When writing the inequality $$-1 \leq \sin(x) \leq 1$$ for $$x \in \R$$, no one feels it necessary to specify that $$\sin(x)$$ cannot be simultaneously equal to both 1 and &minus;1. This situation seems completely analogous.  --JBL (talk) 20:42, 16 June 2024 (UTC)