4/8 Math Functions I

php

#1

Here's my code:



<?php
$round = round(M_PI);
print $round;
?>
<?php
$rounddecimal = round(M_PI, 3);
print $rounddecimal;
?>


It gives me the error:

Oops, try again. Your second call to round() should print a floating point number with exactly 3 digits after the decimal.

can anybody help me as to figure out what i did wrong? it does put out 3 and then 3.142, rounding .0015 up to .002


#2

I think your code is correct, but sometimes the parser codeacademy uses is very picky about the syntax. Looks like you deleted the

and tags that were there before and now the parser can't find your code...

you can fix it by adding and

tags back in, or you can ignore it and move on.

<html>
    <p>
    <?php
    $number = round(M_PI);
    print $number;
    ?>
    </p>
    <p>
    <?php
    $number = round(M_PI,3);
    print $number;
    ?>
    </p>
</html>

#3

desta forma imprimi toda correta mas fique atento as dicas



<?php
// Tente arredondar um número em ponto flutuante para um inteiro
// e imprima-o na tela
// Arredonda pi 3.1416... para baixo
$round = round(M_PI);
print $round; // imprime 3

?>
</p>
<p>
<?php
// Tente arredondar um número em ponto flutuante para 3 casas decmais
// e imprima-o na tela

$round_decimal = round(M_PI, 3);
print $round_decimal;
// imprime 3

?>
</p>