# Math Help - How to calculate integer part from real number?

1. ## How to calculate integer part from real number?

This question could be trivial but I don't know the answer.

Lets assume I have a real number, any real number.
$\forall x\in \mathbb{R}$

for example 1220,74 = 1220.

Of course we can see the integer part directly or we can use calculator or computer. But how to calculate without calculator/computer the $\mathbb{Z}$ part from any real number if exists?

2. Originally Posted by tabularasa
This question could be trivial but I don't know the answer.

Lets assume I have a real number, any real number.
$\forall x\in \mathbb{R}$

for example 1220,74 = 1220.

Of course we can see the integer part directly or we can use calculator or computer. But how to calculate without calculator/computer the $\mathbb{Z}$ part from any real number if exists?
I don't understand your question. How is the number "given". That is, if you cannot "see the integer part directly" what can you see of the number?

3. I'm looking mathematical solution how integer part can be resolved from real number. It is intuitive clear to know the integer part since we see whole real number but if I have to calculate the integer part, how we can technically do that in math? So how we can resolve integer part of any real number?
For example real number's 1200,756 integer number is 1200, how to technically calculate this? Rounding is not mandatory.

4. What do you mean by 'mathematical solution' and 'calculate'? Isn't it just enough to truncate the digits following the decimal place? No calculations are necessary.

If you gave me the number 1200.756, I don't need a formula to tell me that 1200 is the integer I'm looking for.

5. Originally Posted by o_O
What do you mean by 'mathematical solution' and 'calculate'? Isn't it just enough to truncate the digits following the decimal place? No calculations are necessary.

If you gave me the number 1200.756, I don't need a formula to tell me that 1200 is the integer I'm looking for.
Of course we don't need a formula for that. Question is theoretical. But if you need, what the formula could be?

6. This is funny but I think I have an idea.
The following pseudo-code will give you what you want:
X is the real number.

Find number of digits before decimal (this is doable by a simple loop)
Let number of digits be N.

do while (N>=1)
{i=0
do while (X >= 10^N)
{X= X - 10^N
i++
}

firstDigit = i
X = X - firstDigit * 10^N
N = N-1
}

intResult=firstDigit *10^N + secondDigit *10^(N-1) + ... + lastDigit
END

OR simply you can write
=int(X)
in Excel and get the result.

This is really funny... I enjoyed it !!!

-O

7. hehee :-) . Very nice loop. This can be done with several algorithms. But I was looking mathematical formulation. Or could you formulate your loop. At very first there is a problem how to calculate N, number of digits, ok that can be done calculating logarithm from the number, not easy to continue with that. Let's go to back.

So I'm looking mathematical way. You have only your quill, rag paper and candlelight...

8. Originally Posted by tabularasa
This can be done with several algorithms. But I was looking mathematical formulation. So I'm looking mathematical way.
You seem to have a somewhat different view of mathematics.
As the others have told you this is not something that can calculated mathematically.

Now it is a standard theorem that, $\left( {\forall x \in \mathbb{R}} \right)\left( {\exists n \in \mathbb{Z}} \right)\left[ {n \leqslant x < n + 1} \right].$
Put another way: Every real nuber is an integer or is between an integer and its successor.
But that is only an existence theorem, it tells us that the integer part of $x$ exists; but it does not begin to tell us how to find that integer.

9. Originally Posted by tabularasa
I'm looking mathematical solution how integer part can be resolved from real number. It is intuitive clear to know the integer part since we see whole real number but if I have to calculate the integer part, how we can technically do that in math? So how we can resolve integer part of any real number?
For example real number's 1200,756 integer number is 1200, how to technically calculate this? Rounding is not mandatory.
If you want a formula it is f(x)= floor(x).

10. ## Sawyer23

If you still could not get your solution then you should go to other threads of this forum