Jump to content

Talk:Floor and ceiling functions

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Voidxor (talk | contribs) at 23:28, 30 May 2023 (Sign unsigned.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Template:Vital article

WikiProject iconComputer science B‑class Mid‑importance
WikiProject iconThis article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
BThis article has been rated as B-class on Wikipedia's content assessment scale.
MidThis article has been rated as Mid-importance on the project's importance scale.
Things you can help WikiProject Computer science with:

WikiProject iconMathematics B‑class Mid‑priority
WikiProject iconThis article is within the scope of WikiProject Mathematics, a collaborative effort to improve the coverage of mathematics on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
BThis article has been rated as B-class on Wikipedia's content assessment scale.
MidThis article has been rated as Mid-priority on the project's priority scale.

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 (talkcontribs) 01:52, 7 June 2018 (UTC)[reply]

that would be great but I get access denied — Preceding unsigned comment added by Spitzak (talkcontribs) 23:12, 26 July 2022 (UTC)[reply]

prime test

I've added:

Equivalently, This is correct because: is equal to 1 if m divides n, and to 0 otherwise, as can be seen immediately. q.e.d. maimonid (talk) 11:40, 6 January 2019 (UTC)[reply]

See wp:UNSOURCED and wp:NOR. See also wp:CALC and wp:CONSENSUS. - DVdm (talk) 11:43, 6 January 2019 (UTC)[reply]
@DVdm: Do you systematically paralyze any attempt to improve Wikipedia articles with wp:Unsourced ? It is a very bad practice to do so. You are missing the point of Wikipedia. Sources are demanded only when you have a real reason to disagree with a contributor, not because the contributor has not cited his sources. In the case of this article for example, there are full of non cited assertions (e.g. near the beginning of the article). The usual and good way to proceed is to clarify things in the discussion page, or to put a "citation needed" in the article. maimonid (talk) 11:58, 6 January 2019 (UTC)[reply]
And, of course, wp:BURDEN. - DVdm (talk) 12:14, 6 January 2019 (UTC)[reply]
I've not restored the assertion you've deleted. So this has nothing to do with that. I think you answer like a robot (or more precisely, you don't answer, like a robot), so, you are probably a robot, an I have to stop this discussion. maimonid (talk) 12:23, 6 January 2019 (UTC)[reply]
@Maimonid: I agree that DVdm's responses are not very constructive. Here is a more helpful response: there is a discussion in the section directly above this one of the reasons for writing the article in its present form. Before making changes, it would be good to engage with the discussion there -- there are very good reasons not to make the change you suggest, relating to core principles of Wikipedia, as well as to reasonable choices about writing and presentation. Also, the form you've written down does not have clear meaning when n = 1, which is problematic. --JBL (talk) 17:43, 6 January 2019 (UTC)[reply]
@Joel B. Lewis:. Thank you for answering me. Indeed, this was discussed just above, and in fact the formula with reported in the footnotes is exactly the same. Nevertheless, the formula with the infinite bound is very misleading (and the discussion above shows I'm not the only person to think so), as it causes to think there is a limit process while the formula is quite trivial. I may add a small hint that fix that. maimonid (talk) 21:20, 6 January 2019 (UTC)[reply]
@Maimonid: You are welcome. I was worried in your original edit about giving too much weight to this one not-important formula, but I think the current formulation avoids that problem nicely. --JBL (talk) 18:19, 8 January 2019 (UTC)[reply]

ISO codes

I wanted to type the floor function symbols but, although I knew they existed, they were rather hard to find with Google. I even clicked on Wikipedia's Floor and ceiling functions page! Ha. Fat chance that the "new" Wiki would actually have what I'm looking for!  :-)

This is a test. I've added something useful to the page and have a bet with myself that some Wiki editor will find reason to remove my change without finding an alternate way to provide the same useful information. What do I win? Jamesdowallen (talk) 08:25, 28 January 2019 (UTC)[reply]

If you'd spent half as much time making your edit decent (correctly placed, correctly formatted, on topic) instead of writing this dickish message, I wouldn't have had to fix it for you. You're welcome. --JBL (talk) 12:00, 28 January 2019 (UTC)[reply]

Thank you very much, JBL. And, FTR, I 'd be more motivated to spend time improving Wikipedia if moronic and overly-pedantic editors didn't thoughtlessly revert my changes so often. I notice you didn't add the ceiling codes. I'll do that now that you've pointed the way. Thanks again! Jamesdowallen (talk) 16:18, 28 January 2019 (UTC)[reply]

Those are not "ISO codes". They are the decimal values of the Unicode code points, used by HTML character entities. You can use the hex values into a HTML character entity by typing &#x<hex>; most of Unicode is defined using the hex number not the decimal one so this is preferred. I put examples in to replace the other text which did not format correctly anyway. May want to add (using &amp; to get it to print correctly) the source, but please use the hex value.Spitzak (talk) 19:05, 28 January 2019 (UTC)[reply]

There is some message board software which DOES support the decimal codes but does NOT support the hexadecimal codes. I intervened on this page NOT because I had some theoretical idea of what the page 'should' look like, but because, as an ACTUAL Wiki user I found that the page did NOT serve my needs. I wanted the codes because I was composing a message-board post and was surprised to find the codes so hard to come by. (It was low-priority; I actually ended up rewording that post to avoid the need for floor symbols ::whack::) I tried to copy/paste the floor symbols. Doesn't work -- they're all* images. (Why? Do you use images for objects like the word 'the'?  :-) )

I DO know how to convert hexadecimal to decimal, but I did not wade through the Wiki article to find the one place where the useful information was available. Easy, obviously needed, information should be easy to find. Wikipedia used to be wonderful. Increasingly, unfortunately, the information REAL Wikipedia users are likely to want is drowned out in the tedium of structure. I comment on this more at my Talk page. HTH. Jamesdowallen (talk) 09:38, 29 January 2019 (UTC)[reply]

Hope this is addressed with my last edit. Spitzak (talk) 18:12, 29 January 2019 (UTC)[reply]

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)[reply]

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)[reply]
I think I agree with Bastian 51234 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)[reply]
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)[reply]
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)[reply]

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)[reply]

"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)[reply]
(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, (3. * (2.^10 * (1. / 3.))) / 2.^10 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)[reply]

Integral part

In the recent edits, it is asserted that, as Legendre used "partie entière inférieure", the function that he denoted 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)[reply]

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)[reply]
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)[reply]
@DVdm: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)[reply]
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)[reply]
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)[reply]
 DoneAnita5192 (talk) 17:21, 10 June 2021 (UTC)[reply]
@Anita5192: concur. Thx. Tricky - DVdm (talk) 19:04, 10 June 2021 (UTC)[reply]

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)[reply]

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)[reply]
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)[reply]
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)[reply]
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)[reply]
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)[reply]
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)[reply]
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)[reply]
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)[reply]
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)[reply]
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)[reply]
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 (talkcontribs) 20:23, 28 January 2022 (UTC)[reply]

"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 Wikipedia:Redirects for discussion/Log/2022 May 19#Greatest integer 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)[reply]

Definition of "integral part"

The article defines [·] such that [−2.4] = −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".[1][2][3] 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.[4][5][6] The statement in the latter source that [−2.5] = −3 clearly contradicts the present definition in our article.  --Lambiam 06:19, 23 May 2022 (UTC)[reply]

I very much suspect the idea that [x]] means round-towards-zero and not floor is a made-up "fact" by wikipedia.Spitzak (talk) 17:18, 23 May 2022 (UTC)[reply]
I concur. The standard convention in mathematics is that and denote the same thing (unless means something completely different, such as the Iverson bracket).—Emil J. 11:33, 20 December 2022 (UTC)[reply]

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)