Skip to main content

Divide integer and get integer value with intdiv() in PHP7

When an integer number is divided by another integer number, output will be in integer with some decimal values in PHP.

3 ways of removing decimal value with integer division.

  1. round()
  2. floor()
  3. intdiv()

For example, when an integer 7 is divided by 2, output will be 3.5. Decimals can be removed with PHP built in functions round() or float() as shown below.

// Usage of round function rounds it to upper integer value
round ( 7/2 ) ;  // gives output 4
// Usage of floor function gives the correct integer without decimals
floor ( 7/2 ) ; // gives output 3

PHP 7 supports new built in function intdiv() which does same as division followed by floor() function. With the introduction of intdiv function, using floor() is not required in PHP7.

// intdiv() function in PHP7 is equivalent of integer division followed by floor() funcion in earlier versions of PHP.
intdiv ( 7 ,  2 ) ;  // gives output 3

Please keep an eye on the syntax of intdiv ( dividend , divisor ).  It requires to use comma in place of division character.

Popular posts from this blog

eLitmus pH test for freshers

eLitmus has became more famous in conducting pH test for the fresh graduates in India. They will evaluate candidates across India and to provide a standard benchmark against which companies can compare them.

Who can apply

Candidates having/pursuing a degree in BE/B.Tech, MCA, ME/M.Tech or M.Sc(CS/IT) can apply for the pH test.

Companies recruiting from pH test

List of companies

Look at test centers

Check the upcoming pH tests

Look at the testimonials

Read what the candidates appeared for this exam says about eLitmus.

Test Pattern

Test duration : 2 hours
No of questions : 60

It will be asked from 3 categories,


20 : Problem solving
20 : Verbal ( You need to read the paragraph and answer the questions )
20 : Quantitative ( Data interpretation )

Four options will be provided for each question. Test will be conducted online.

Payment methods

Fresh graduates appearing for the test has to pay Rs 920/- as a test fee.

They can pay online or send a DD or in cash at Bangalore eLitmus office.

By Online: If y…