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

  • Home
  • SEARCH
  • 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 4590204
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:12:55+00:00 2026-05-21T22:12:55+00:00

pack(‘H*’, dechex(12345678900)) /* on 32bit */ != pack(‘H*’, dechex(12345678900)) /* on 64bit */ why

  • 0
   pack('H*', dechex(12345678900)) /* on 32bit */  
!= pack('H*', dechex(12345678900)) /* on 64bit */

why ?

  • 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-05-21T22:12:56+00:00Added an answer on May 21, 2026 at 10:12 pm

    I don’t know how to fix it, but I think I know why this is happening. No bug here – straigt out from the manual http://php.net/manual/en/function.dechex.php

    The largest number that can be converted is 4294967295 in decimal resulting to “ffffffff”

    I do not know what exactly is happening “inside” php, but you probably are causing 32 bit unsigned integer to overflow (12,345,678,900 > 4,294,967,295). Since on 64 bit this limit should be 18,446,744,073,709,551,615, dechex is returning “correct” values (32 vs 64 bit diffirence doesn’t seem to be documented and I might be wrong since I don’t have 64 bit system for testing).

    //Edit:

    As a last resort you could use GMP extesion to make your own hecdex function for 32 bit system, but that is going to produce lots and lots of overhead. Probably going to be one of the slowest implementations known to the modern programming.

    //Edit2:

    Wrote a function using BCMath, I’m on a Windows at the moment and was struggling finding correct dll for GMP.

    function dechex32($i) {
        //Cast string
        $i = (string)$i;
        //Initialize result string
        $r = NULL;
        //Map hex values 0-9, a-f to array keys
        $hex = array_merge(range(0, 9), range('a', 'f'));
            //While input is lagrer than 0
            while(bccomp($i, '0') > 0) {
                //Modulo 16 and append hex char to result
                $r.= $hex[$mod = bcmod($i, '16')];
                //i = (i - mod) / 16
                $i = bcdiv(bcsub($i, $mod), '16');
            }
        //Reverse result and return
        return strrev($r);
    }
    
    var_dump(dechex32(12345678900));
    /*string(9) "2dfdc1c34"*/
    

    Didn’t test thoroughly but seems to work. Use as a last resort – rough benchmarking with 100,000 iterations did show, that it’s ~40 times slower than native implemetation.

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

Sidebar

Related Questions

I need to pack all my js, but need to edit it going into
How to pack python libs I'm using so I can distribute them with my
How can I find out which Service Pack is installed on my copy of
My understanding of the Git pack file format is something like: Where the table
I've created a language pack for a site before, but I'm not sure if
I've seen that a Processor Pack is available for Visual Studio 6, however it
I have VB application that requires visual service pack 6 to run , now
I'm trying to use some of the new MFC feature pack controls on an
I'm updating some of our legacy C++ code to use the MFC feature pack
i've noticed that plenty of games / applications (very common on mobile builds) pack

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.