0

I am calculating a number which I use in another calculation. the problem is this number could be 67.9699 I want it to say 67.96 without rounding up or down just chop the other digits of. I was hoping the floor function would do this like:

$num2 = floor(($num1/5)*100)/100;

How ever this is still rounding the number up to 67.97 is there a away to stop this. Any help welcome

Ria
  • 516
  • 6
  • 24

3 Answers3

3

It's working well for me, try this:

echo floor(67.9699 * 100) / 100;

Demo Online

By the way, number_format() rounds the number.

izn
  • 300
  • 1
  • 7
0
$num2 = substr($num2,0,5);
echo $num2; 

If you want to use the number again as float

$num2 = floatval($num2);
spod
  • 406
  • 3
  • 5
  • 19
0

You can use number_format();

number_format

peterdoesco.de
  • 529
  • 3
  • 19