php 2 decimal places without rounding

pakainfocom profile image pakainfo ・1 min read

Today, We want to share with you php Two Decimal Places without rounding off.In this post we will show you PHP dropping decimals without rounding up, hear for PHP Floating numbers truncating to two digits without rounding we will give you demo and example for implement.In this post, we will learn about Cut off decimal numbers to 2 places but should NOT round it using ceil neither floor with an example.

php Two Decimal Places without rounding off

There are the Following The simple About php Two Decimal Places without rounding off Full Information With Example and source code.

Two Decimal Places without Rounding (Positive and Negative)

$my_number = 0.9999999; 
echo number_format(floor($my_number*100)/100, 2); //Returns 0.99

Example 1:

floor(2.500000550 * 100) / 100;

Example :2

$rounded = floor($float*100)/100;

Example : 3

$rounded = 0.01 * (int)($float*100);

How to make number_format() not to round numbers up

$number = intval(($number*100))/100;


$number = floor(($number*100))/100;

You can visit my Article with More Examples : click here

Posted on by:

pakainfocom profile



My name is Angular King. I'm a full-stack developer, entrepreneur and owner of Pakainfo. I live in India and I love to write


Editor guide