**PHP => There are three functions available toround off a decimal value**

1) Exact round off with and without precision ( if x > 0.5 then taken as x=1 and x < 0.5 then taken as x=0 )

2) Rounded up to nearest integer ( if x > 0 then taken as x=1 and x < 0 then taken as x=0 )

3) Rounded down to nearest integer ( if x > 1 then taken as x=1 and x < 1 then taken as x=0 )

*1) syntax: round(number,precision,mode);*

**Example:(1) (without precision)**

1 2 3 |
<?php $x=123.51; $y=110.49; echo "Result = ". round(x) ; // Result = 124 echo " Result = ". round(y) ; // Result = 110 ?> |

**Example:(2) (with precision)**

1 2 3 |
<?php $x=123.517896; $y=110.49434355; echo "Result = ". round(x,3) ; // Result = 123.518 echo " Result = ". round(y,1) ; // Result = 110.5 ?> |

**Example:(3) (with mode properties)**

1 2 3 4 |
<?php $x=123.51; $y=110.49; echo "Result = ". round(x , 0 , PHP_ROUND_HALF_UP ) ; // Result = 124 echo " Result = ". round(y , 0 , PHP_ROUND_HALF_DOWN ) ; // Result = 110 ?> |

Mode properties:

a) PHP_ROUND_HALF_UP -> Default. Rounds number up to precision decimal, when it is half way there. Rounds 1.5 to 2 and -1.5 to -2

b) PHP_ROUND_HALF_DOWN -> Round number down to precision decimal places, when it is half way there. Rounds 1.5 to 1 and -1.5 to -1

c) PHP_ROUND_HALF_EVEN -> Round number to precision decimal places towards the next even value

d) PHP_ROUND_HALF_ODD -> Round number to precision decimal places towards the next odd value

*2) syntax: ceil(number)*

Example:

1 2 3 |
<?php $x=123.51; $y=110.49; echo "Result = ".round(x) ; // Result = 124 echo " Result = ".round(y) ; // Result = 110 ?> |

**3) syntax: floor(number);**

Example:

1 2 3 |
<?php $x=123.51; $y=110.49; echo "Result = ".round(x) ; // Result = 124 echo " Result = ".round(y) ; // Result = 110 ?> |