0

I was taking some PHP skills test when I encounter this question.

Output of this code:

<?php echo (int)(77.74 * 100);

When I checked it's output, it was 7773. Can anyone explain why it's output is 7773 rather than 7774?

I further investigated and found that following code snippet also has similar output.

<?php 
for( $i = 64.74; $i <= 81.74; $i++ ) {
    echo ( int )( $i * 100 ) . ", ";
}

And here is the output:

6473, 6573, 6673, 6773, 6873, 6973, 7073, 7173, 7273, 7373, 7473, 7573, 7673, 7773, 7873, 7973, 8073, 8173,
DarkBee
  • 16,592
  • 6
  • 46
  • 58

0 Answers0