Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

While it is trivial to simply remove the fractional part of an irrational or rational number, and in programming I could just use the floor() or ceil() functions, I was wondering how such calculation is done using basic arithmetic.

In other words, how can I get the integer part of a (base-10) number using merely addition, subtraction, multiplication and division?

Perhaps this is trivial, but after a bit of trying and a bit of googling, I couldn't quite get my head around it. Maybe it is not so trivial after all?

share|improve this question
    
I don't think that it can be done, because no member in the set of rational numbers, other than 0 and 1, has any privileged position under these operations. –  Klortho Nov 21 '12 at 19:59

1 Answer 1

up vote 6 down vote accepted

It's impossible.

If you consider the set of all functions $P$ containing $f(x) = x$ and when $f,g \in P$ we have the sum $f(x)+g(x) \in P$, etc. then

Theorem $\text{floor}$ is not contained in $P$.

proof: We prove this by finding a property that everything in $P$ has but $\text{floor}$ does not. All functions in $P$ are continuous, but floor is not.

share|improve this answer
2  
You mean that $P={\bf Z}(X)$ (rational functions with integeral coefficients)? (Which, incidentally, is the same as ${\bf Q}(X)$.) ;) –  tomasz Nov 21 '12 at 20:47
    
It sounds very convincing, but I'm afraid my mathematical skills are too limited to follow your reasoning. Does this mean that floor() is a unique mathematical operation that cannot be expressed by other mathematical operations (log, sum, exp), or is it only impossible with basic arithmetics? –  Abel Nov 21 '12 at 21:03
    
@Abel, Actually this is very simple and you will understand it fine. The idea is that floor has a special property that +, -, *, / and even log and exp don't have (but I didn't include log and exp in the proof), so you can never build it out of those operation. It's exactly like you said, it's a unique operation. –  sperners lemma Nov 21 '12 at 21:06
1  
that "special property" is that it jumps (meaning it's not continuous somewhere): floor(0.98)=0, floor(0.99)=0, floor(1)=1, floor(1.01)=1 none of the other functions have a jump like that, and combining them doesn't create a jump. –  sperners lemma Nov 21 '12 at 21:07
    
The jumping example makes it clear, thanks. Somehow it sounds odd, though you probably know what you are talking about. I mean, you can express multiplication with addition, you can express log with power series and so on. I guess I just never gave it too much thought until today when I found out I couldn't easily find a simple solution. –  Abel Nov 21 '12 at 21:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.