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 8332049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:36:22+00:00 2026-06-09T02:36:22+00:00

If I use the formula document_height – window_height = max_scroll_position It evaluates to 1

  • 0

If I use the formula

document_height - window_height = max_scroll_position

It evaluates to 1 or 0, although I believe it should consistently evaluate to 0.
For e.g, on firefox Open console, Scroll to the bottom of the page on http://stackoverflow.com and do the following on console :

($(document).height() - $(window).height()) - $(document).scrollTop()

I get 1 as the answer (remember to keep the scroll position to bottom most)
On jquery.com however, doing the above gives 0

What am I missing ?

  • 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-09T02:36:24+00:00Added an answer on June 9, 2026 at 2:36 am

    After some testing, that extra 1 pixel is definitely rounding error. All three of those variables (document height, window height and scroll top) are maintained either to some greater internal precision or to the scale of the unzoomed browser window, then scaled and rounded as needed to suit the requirements of the JavaScript properties. In some edge cases, which become more likely as the zoom ratio increases, those values round in a way that produces the inconsistent results you saw.

    Unless you’re adjusting one of more of those variables many times rapidly based on the values of the other variables, this rounding error is unlikely to cause any problems visible to the user. If you have to adjust them frequently, then you should probably cache the adjusted numbers, and use your cached version instead of the browser-reported numbers for further calculations.

    [Note: I was eventually able to get a rounding error of -1 using the formula in the OP, at a zoom of 250% in Firefox.]

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

Sidebar

Related Questions

I'm trying to use this formula in JAVA : (-ln(1-L))/L I'm not sure how
I'm trying to use the SUMPRODUCT formula to get the sum of money (O
What formula would I use in a persisted column so that I can add
In an Excel formula you can use =ISERR(A1) or =ISERROR(A1) In a VBA macro
I am trying to use a slot of type formula. But formula isn't a
In Excel, what formula can I use to repeat text in one cell, for
When I use a formula to ad the name it works (first series: Max.
I am trying to use a formula which requires me to mix the characters
I'm trying to use the formula from (www.movable-type.co.uk/scripts/latlong.html) to return a destination point giving
I am trying to use a formula to get a letter of the alphabet.

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.