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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:31:22+00:00 2026-06-17T15:31:22+00:00

I’ve got two integers and I need to convert them into a long. I’m

  • 0

I’ve got two integers and I need to convert them into a long. I’m totally lost on how to do this. The two integers that I need to convert are:

INT 1: 60850985 
INT 2: 59150141

I need a method that converts two integers into a long. If you can post one, that’d be great.

When I say converting to a long, I’m wondering how you would do the equivalent of (long) from java in PHP


Let me be completely clear here:
I’m receiving two ints from the client, then I need to convert them to a long, then the single long is to be used again as a single int.

In essence, I need to take two ints and convert them into a single int. An example of how this is done in java would be:

  long $intA = (long) readInt();
  long $intB = (long) readInt();
  return ($intA << 32) + $intB;
  • 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-17T15:31:24+00:00Added an answer on June 17, 2026 at 3:31 pm

    I used regular addition:

    $int1 = 60850985;
    $int2 = 59150141;
    $result = $int1 + $int2;//120001126
    

    Here’s a quote from the PHP manual:

    The size of an integer is platform-dependent, although a maximum value
    of about two billion is the usual value (that’s 32 bits signed).
    64-bit platforms usually have a maximum value of about 9E18. PHP does
    not support unsigned integers. Integer size can be determined using
    the constant PHP_INT_SIZE, and maximum value using the constant
    PHP_INT_MAX since PHP 4.4.0 and PHP 5.0.5.

    If you want to deal with large numbers use GMP ( http://www.php.net/manual/en/book.gmp.php ) or BCMath ( http://www.php.net/manual/en/book.bc.php ).

    To elaborate on what AgentConundrum said, there isn’t a need to cast an integer to a long in PHP. PHP is a dynamic language which means that generally, for operations on fundamental types, there is no need for casting (unless it is for some explicit purpose – i.e. a float to an integer), as PHP handles it for you.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.