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,890 questions

51,821 answers

573 users

How to use fmod() function to get the floating-point remainder (modulo) of the division x/y in PHP

1 Answer

0 votes
echo "fmod(4.3 . 2.0) = " . fmod (4.3 , 2.0) . "<br />";
echo "fmod(18.5 . 4.2) = " . fmod(18.5 , 4.3) . "<br />";
echo "fmod(5.1 . 3.0) = " . fmod(5.1 , 3.0) . "<br />";
echo "fmod(-5.1 . 3.0) = " . fmod(-5.1 , 3.0) . "<br />";
echo "fmod(5.1 . -3.0) = " . fmod(5.1 , -3.0) . "<br />";
echo "fmod(-5.1 . -3.0) = " . fmod(-5.1 , -3.0) . "<br />";
echo "fmod(0.0 . 1.0) = " . fmod(0 , 1.0) . "<br />";
echo "fmod(-0.0 . 1.0) = " . fmod(-0.0 , 1.0) . "<br />";
echo "fmod(3.1 . INF) = " . fmod(3.1 , INF) . "<br />";


/*
run: 

fmod(4.3 . 2.0) = 0.3
fmod(18.5 . 4.2) = 1.3
fmod(5.1 . 3.0) = 2.1
fmod(-5.1 . 3.0) = -2.1
fmod(5.1 . -3.0) = 2.1
fmod(-5.1 . -3.0) = -2.1
fmod(0.0 . 1.0) = 0
fmod(-0.0 . 1.0) = 0
fmod(3.1 . INF) = NAN

*/

 



answered Jun 18, 2016 by avibootz
...