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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:24:10+00:00 2026-06-15T15:24:10+00:00

The Twitter API returns IDs that are 64 bit integers, such as 276403573577891842. I

  • 0

The Twitter API returns IDs that are 64 bit integers, such as 276403573577891842. I want to see if one Tweet is newer than another by comparing their ID’s.

Is there a clever way to compare two 64 bit integers to see which is greater in JavaScript which only supports 32 bit integers?

  • 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-15T15:24:12+00:00Added an answer on June 15, 2026 at 3:24 pm

    Assuming the API is returning strings which are then parsed into ints, there are two ways to do this – a split way and a pad way;

    Split.
    The idea here is to split the data into a size the environment can handle. Largest 32-bit number is 0xFFFFFFFF or 4294967295. Now 4294967295..toString().length === 10. So all dec with str length <= 9 should be 32-bit safe.

    function compare(a,b){
        var aa = [0,0,0], ba = [0,0,0], i = 3;
        while (a.length) aa[--i] = parseInt(a.slice(-9)), a = a.slice(0,-9);
        i = 3;
        while (b.length) ba[--i] = parseInt(b.slice(-9)), b = b.slice(0,-9);
        if (aa[0] === ba[0]){
            if (aa[1] === ba[1]) {
                if (aa[2] === ba[2]) return 0;
                else if (aa[2] > ba[2]) return 1;
                return -1;
            } else if (aa[1] > ba[1]) return 1;
            return -1;
        } else if (aa[0] > ba[0]) return 1;
        return -1;
    }
    // a > b: 1, a = b: 0, a < b: -1
    

    Pad.
    The idea this time is to do a string comparison, but to do that we must first make sure the (string) numbers have the same length; i.e. pad them with 0s. This time '18446744073709551615'.length === 20 so

    function pad(str, len) { // Your fav. padding fn
        var pre = '0';
        len = len - str.length;
        while (len > 0) {
            if (len & 1) str = pre + str;
            len >>= 1;
            pre += pre;
        }
        return str;
    };
    
    a = pad('276403573577891842',20);
    b = pad('50',20);
    

    Now you can use a === b, a < b, a > b so normal (except you’re using strings and not int).

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

Sidebar

Related Questions

Is there a twitter API that returns mood? I have seen some websites that
When click this https://api.twitter.com/1/followers/ids.json?screen_name=USER_NAME It returns; {ids:[XXXXXXXXXXX,XXXXXXXXXXXX,XXXXXXXXXXX,.........],next_cursor:0,next_cursor_str:0,previous_cursor:0,previous_cursor_str:0} And How can i keep these ids
Twitter's REST API returns a in_reply_to_status_id value for tweet statuses, yet the Search API
Is there an API (Twitter API does not provide this) that I can use
I studied the Twitter API Documentation today. Only find that we could use Twitter
I'm working with a project that use Twitter API to get mentions timeline of
I started learning the Twitter API. I want to make a simple search for
The Twitter API returns this value for the Twitter account 'image_url': http://a1.twimg.com/profile_images/75075164/twitter_bird_profile_bigger.png In my
I'm talking about ones encoded in the format in which the twitter API returns
Here is a sample query which returns the twitter ids of followers of examplename:

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.