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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:53:04+00:00 2026-05-25T13:53:04+00:00

I need to convert a hexadecimal value to a decimal integer. Is there some

  • 0

I need to convert a hexadecimal value to a decimal integer. Is there some unit that can do this?

On the web I have found something about it but it is not helping me much. I understood that using inline asm it is possible to represent it as a packed array of four 32 bit Integer. I have found as convert a int32 or int64 to int128 and viceversa, but not found nothing for take for example two int64 and to do a int128 and too i have found issue searching in asm inline something that emule div operator, mul operator and sum operator.

So I ask if someone can help me to solve this problem. My objective is to take a string in hexadecimal and convert it in decimal and after that calculate the equivalent value in base 35 (0..9, A..Z).
Thanks very much.

  • 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-25T13:53:04+00:00Added an answer on May 25, 2026 at 1:53 pm

    If you convert the hexadecimal string into an array of bytes (see SysUtils for that) you can use the follewing code to convert it into base 35:

    function EncodeBaseX( const Values: array of Byte; var Dest: array of Byte; Radix: Integer ): Boolean;
    var
      i,j,Carry: Integer;
    begin
      // We're unsuccesful up to now
      Result := False;
    
      // Check if we have an output buffer and clear it
      if Length( Dest ) = 0 then Exit;
      System.FillChar( Dest[ 0 ], Length( Dest ), 0 );
    
      // fill in the details
      for i := 0 to High( Values ) do begin
        Carry := Values[ i ];
        for j := 0 to High( Dest ) do begin
          Inc( Carry, Radix * Dest[ j ] );
          Dest[ j ] := Carry and $ff;
          Carry := Carry shr 8;
        end;
        if Carry <> 0 then Exit; // overflow
      end;
    
      // We're succesful
      Result := True;
    end;
    
    {Bytes: array of byte (0..255); Dest: array of Byte(0..Radix-1)}
    function DecodeBaseX( const Bytes: array of Byte; var Dest: array of Byte; Radix: Integer ): Boolean;
    var
      i,j,Carry: Integer;
      B: array of Byte;
    begin
      // We're unsuccesful up to now
      Result := False;
    
      // Copy data
      if Length( Bytes ) = 0 then Exit;
      SetLength( B, Length( Bytes ) );
      System.Move( Bytes[ 0 ], B[ 0 ], Length( B ) );
    
      // fill in the details
      for i := High( Dest ) downto 0 do begin
        Carry := 0;
        for j := High( Bytes ) downto 0 do begin
          Carry := Carry shl 8 + B[ j ];
          B[ j ] := Carry div Radix; Carry := Carry mod Radix;
        end;
        Dest[ i ] := Carry;
      end;
    
      // Check if we collected all the bits
      Carry := 0;
      for i := 0 to High( B ) do Carry := Carry or B[ i ];
    
      // We're succesful if no bits stayed pending.
      Result := ( Carry = 0 );
    end;
    

    Then transform the base 35 bytes into characters:

    function EncodeKeyToString( const Num128Bits: array of Byte ): Ansistring;
    var
      Src:   array [0..15] of Byte; // your 128 bits
      Dest:  array [0..24] of Byte;
      i:     Integer;
    const
      EncodeTable: AnsiString = '0123456789ABCDEFGHIJKLMNPQRSTUVWXYZ'; 
      // O is not present to make base 35. If you want a different code, be my guest.
    begin
      // Convert to an array of 25 values between 0-35
      System.Move( Num128Bits[ 0 ], Src[ 0 ], Length( Src ) ); // Copy data in our private placeholder
      DecodeBaseX( Src, Dest, 35 );    
    
      // Convert to a representable string
      SetLength( Result, Length( Dest ) );
      for i := 0 to High( Dest ) do begin
        Assert( Dest[ i ] < Length( EncodeTable ) );
        Result[ i + 1 ] := EncodeTable[ 1 + Dest[ i ] ];
      end;
    end;
    

    I don’t think you need 128 bit math..

    Good luck!

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

Sidebar

Related Questions

I need to convert integer value into hexadecimal. I have done with some logical,
I need convert a String to a decimal in C#, but this string have
I have unsigned char[] that contains binary text. I need to convert this binary
I need to convert Locale to String. How can I do that? I have
MASSIVE EDIT: I have a long int variable that I need to convert to
I am trying to convert a decimal integer into hexadecimal. I've done a lot
I have a hexadecimal value, 07A5953EE7592CE8871EE287F9C0A5FBC2BB43695589D95E76A4A9D37019C8 Which I want to convert to a byte
I have a problem I need to convert char [] to String, hexadecimal format
I have a text file with hexadecimal values. Now I need to convert the
I have a hexidecimal string that I need to convert to a byte array.

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.