Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,938 questions

51,875 answers

573 users

How to use floor() function to round fractions down in PHP

1 Answer

0 votes
echo "floor(-3.14) = " . floor(-3.14) . "<br />";
echo "floor(3.14) = " . floor(3.14) . "<br />";
echo "floor(1.3) = " . floor(1.3) . "<br />";
echo "floor(2.7) = " . floor(2.7) . "<br />";
echo "floor(-4.2) = " . floor(-4.2) . "<br />";
echo "floor(-2.8) = " . floor(-2.8) . "<br />";
echo "floor(-0.0) = " . floor(-0.0) . "<br />";
echo "floor(4.3) = " . floor(4.3) . "<br />";   
echo "floor(9.999) = " . floor(9.999) . "<br />"; 


/*
run: 

floor(-3.14) = -4
floor(3.14) = 3
floor(1.3) = 1
floor(2.7) = 2
floor(-4.2) = -5
floor(-2.8) = -3
floor(-0.0) = 0
floor(4.3) = 4
floor(9.999) = 9

*/

 



answered Jun 18, 2016 by avibootz

Related questions

1 answer 124 views
1 answer 103 views
1 answer 114 views
1 answer 127 views
127 views asked Jan 12, 2017 by avibootz
2 answers 96 views
96 views asked Jun 8, 2022 by avibootz
...