What you need to do (integer) in this example?

What you need to do Integer in this example?
$a = 0.66; // type string
$a = (integer) $a;
echo $a;
?>
If he rounds up the number? I have deduced (0), but I've seen examples where it was rounded up to (1).
July 8th 19 at 11:50
4 answers
July 8th 19 at 11:52
Rounding in this case should be 1 for this function is, but this code just discards the fractional part.
So he rounds or not? Php/su says: When converting from floating point to integer, the number will be rounded towards zero. And in this case, the code only works when there is (1), i.e. the rounding is to zero, and by (1). - Ramona.Lesch commented on July 8th 19 at 11:55
: 0.66 gives 0, it is towards zero, or rather, less. - mazie.Towne commented on July 8th 19 at 11:58
July 8th 19 at 11:54
You are confusing type conversions and rounding. Rounding type round, ceil or floor lead float to the nearest integer, highest integer and the lowest integer, respectively. Casts the same - leave only the portion of data that fits in the result type.
Yeah, that was probably the truth. So the instructions above the code that is rounding? - Ramona.Lesch commented on July 8th 19 at 11:57
facepalm.jpg
no, in the above code, the type cast float ->int. The comment "of type string" on the second line is not correct. - mazie.Towne commented on July 8th 19 at 12:00
July 8th 19 at 11:56
Casts the variable to type integer.
The conversion to integer.
With the rounding in (1)??? - Ramona.Lesch commented on July 8th 19 at 11:59
July 8th 19 at 11:58

Find more questions by tags PHP