[ create a new paste ] login | about

Link: http://codepad.org/5hIdQh4w    [ raw code | output | fork ]

PHP, pasted on May 30:
1
2
3
4
5
6
7
8
9
10
11
12
<?php

function roundPrice($price)
{
    $intVal = intval($price);
    if ($price - $intVal < .50) return (float)$intVal;
    return $intVal + 0.99;
}

var_dump(roundPrice(4.39));
var_dump(roundPrice(4.79));
var_dump(roundPrice(4.50));


Output:
1
2
3
float(4)
float(4.99)
float(4.99)


Create a new paste based on this one


Comments: