This question already has answers here:
What is the difference between '/' and '//' when used for division?
(16 answers)
Closed 8 years ago.
why does one give a different end result than the other in python. When I type in print(25/10) the result is 2.5.
Yet when I type print(25//10) it is 2. Could anyone tell me why?
// used for Floor Division - The division of operands where the result is the quotient in which the digits after the decimal point are removed.
Related
This question already has answers here:
Why does integer division yield a float instead of another integer?
(4 answers)
Why does floating-point arithmetic not give exact results when adding decimal fractions?
(31 answers)
Closed 1 year ago.
I've learnt that python supports very large numbers with int itself.
But in this case :
print(int(12630717197566440579/10))
My answer is
1263071719756644096
and not
1263071719756644057
As it's supposed to be.
Can someone tell me why?
This question already has answers here:
Is floating point math broken?
(31 answers)
Floating Point Numbers [duplicate]
(7 answers)
Closed 4 years ago.
I am trying to understand the decimal rounding behavior in python. What I find strange is the following:
1) Multiplying 70 by 11.46950 gives me 802.865
2) Multiplying 70 by 11.46750 gives me 802.7249999999999
Why is there extra precision in the second case and not the first case? I understand that internally, the decimal cannot be represented exactly. But that reason should also apply to the first case as well?
I am using python3.6.
Thanks
This question already has answers here:
Why does integer division yield a float instead of another integer?
(4 answers)
Closed 6 years ago.
I was writing a Python 3.5.2 program which includes division.
When I ran the following:
>>> 10/2
5.0
Though the answer is correct, it has a decimal point. What should be done to get quotient without decimal point, for example, 10/2 should yield 5, not 5.0?
Check out this answer. In Python 3 Integer division is performed using the // operator, and the regular division operator can yield float. Check 1/2 for example - if you get 0.5, that's not Integer division, 0 is. IDLE is irrelevant here.
This question already has answers here:
How can I force division to be floating point? Division keeps rounding down to 0?
(11 answers)
Closed 9 years ago.
When I do a division in Python/Pandas (e.g. 47/100) how do I show the decimal value of the answer, because at the moment it just shows as 0?
Thanks in advance.
If you're using python2.x, you need to "floatify"1 one of your numbers:
float(47)/100
47.0/100
As python2.x will do integer division if both numbers in the division are integers.
1floatify: Forcing a number to be a float
This question already has answers here:
What is the difference between '/' and '//' when used for division?
(16 answers)
Two forward slashes in Python
(3 answers)
Closed 10 years ago.
What Does this // mean in PYTHON
I know it is some sort of division in python
like
6.0//5 is 1.0
6.0//4 is 1.0
6.0//2 is 3.0
6.8//5.3 is 1
from this I think it just returns integer solution for non integer division
and instead of rounding it just cut's end off is it true ? and if it is not
then what it does ? rounding
I found answer sorry i will delete this post :)
Floor Divison. I.e. round down to nearest int.