Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9192461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:55:48+00:00 2026-06-17T20:55:48+00:00

How can the below be possible: $varnum = 4; if( $varnum/4 – floor($varnum/4) !==

  • 0

How can the below be possible:

$varnum = 4;
if( $varnum/4 - floor($varnum/4) !== 0){
    echo 'foo';
}

This echoes ‘foo’ on my server running PHP 5.1.6. If i change the operator to == I get the same results.

I have no idea why, but could it possibly be because “==” is “equals” and “!==” is “Not identical”? How then would I make them identical? I guess in javaScript I would “parseInt”, but there is no such thing in PHP, right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:55:49+00:00Added an answer on June 17, 2026 at 8:55 pm

    The reason this fails is because in PHP, the floor function returns a float, despite the fact that the value is always a whole number. You can see this in the documentation here: http://php.net/manual/en/function.floor.php

    You’re doing a fixed type comparison of that float to an integer zero, so the result is false, regardless of whether the value is actually zero.

    To fix this, either:

    • cast the output of floor to an integer – either intval(float(...)) or (int)float(..)
    • use != instead of !==.
    • use 0.0 instead of just 0 to compare against.

    In case you’re wondering why floor() would return a float rather than an integer, it’s because the input is a float. The float data type has a larger possible range than integer, and thus it is possible to call floor() on a value that would be too big to hold in an integer. Therefore it would not be safe for the function to return an integer; it returns a float instead so that it can guarantee the result will be correct.

    It may seem odd at first glance, but hopefully that explains the logic behind it for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In android the Toggle buttons are looks like below - Can we modify this
Can the below programming structure is possible in VBScript.Where ProgA will start and after
So I have this JSP search function as you can see below: <% String
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index Below I have a
I have this enum: public enum Direction { LEFT, RIGHT, ABOVE, BELOW } Can
Possible Duplicate: Why can't I fetch www.google.com with Perl's LWP::Simple? code below can be
As you can see below, I have Parallel.For loop. If run the program while
From the disassembly code below can I assume that the location 43E010 is a
The simple code block below can be served up in a static HTML page
I'm using graphviz (dot) to generate the graph you can see below. The node

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.