This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Functions, Part I Forum

View Course » View Exercise

989 points
513abe288e235d66f6001504_280724103
Submitted by
Rez Adential
about 4 years ago

Math Functions I bug?

Anyone care to share code that works for Math Functions I exercise? I have not seen anything on the forums that someone has figured out a way around this.

Here is my code in case I might be wrong,

<?php
// Try rounding a floating point number to 3 decimal places
// and print it to the screen
$round = round(MPI);
print "{$round}";
$round
decimal = round(4.532432, 4);
print "{$round_decimal}";
?>


0 votes

permalink

Hi rez
This might work
$round = round(M_PI);
print $round;
?>



<?php
$rounddecimal = round(4.532432, 4);
print $rounddecimal;
?>

683 points
67cea673ddb964518ae6c5764366ab59?s=140&d=retro
Submitted by
seb204l
about 4 years ago

2 Comments

513abe288e235d66f6001504_280724103 Rez Adential about 4 years ago

I figured out the problem only moments later. Thanks for helping tho :D

513abe288e235d66f6001504_280724103 Rez Adential about 4 years ago

I put all of my code between one pair of php tags. I need to pay better attention next time lol


0 votes

permalink

$rounddecimal = round(4.532432, 4);
print "{$round_decimal}";

$rounddecimal and $round_decimal aren't the same.

318 points
51e9365c52f863f980001c4f_293692206
Submitted by
Benjamin Esh
about 4 years ago