0
Is there any way of getting only the int part of a number after division?
e.g. 3/2 = 1.5. how to get only 1 as the answer?
4 ответов
+ 3
The arithmetic operators between primitive number data types return the type of the one with highest precision.
So if you have 3 / 2 the answer is 1 because an int divided by an int gives an int.
If you have 3.0 / 2 the answer is 1.5 because of the highest precision and if you want to get the int value of it, you just cast it to int, like so
int(3.0 / 2) or
(int)(3.0 / 2)
sorry, didnt saw the php tag.
+ 3
yes you can
int a = 5;
int b = 3
int c = a/b;
"c will produce 1 as the result"
0
convert to string. cut out your int xD
0
Yes, there probably is a way.