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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:27:30+00:00 2026-05-27T06:27:30+00:00

I have two character arrays (each of many bytes in length; for example each

  • 0

I have two character arrays (each of many bytes in length; for example each can be 10-12 bytes) and they represent a number in binary format. I want to check if one number is larger than the other. What is the most efficient way to check which of the two is the largest? Are there bitwise operations that one can perform to efficiently determine this?

  • 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-27T06:27:30+00:00Added an answer on May 27, 2026 at 6:27 am

    I think what you can do is firstly use two pointers to point at the first nonzero byte in both (from the left). If now the two effective lengths are different, output the longer one. I mean, let’s assume that first is 10 bytes and second is 12 bytes. Byte 4 (first[3]) is the first nonzero byte in first, and byte 2 (second[1]) is the first nonzero byte in second. Now the effective length of first is 7 bytes, while that of second is 11. Clearly, second is larger.

    Now for equal effective lengths. Compare the bytes. If equal, go to the next. Otherwise, the larger byte exists in the larger number and we finish.

    You can speed this operation up by comparing register-sized chunks (I mean chunks that fill the whole register), because if both chunks are equal you’ll skip a number of comparisons equal to the size of the register in bytes… if they are unequal, you can compare byte-by-byte, or you can even compare half-size by half-size firstly… if equal, skip to the other half. If different, then compare quarter-size by quarter-size, and so on before comparing byte-by-byte (this is analogous to binary search).

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

Sidebar

Related Questions

I have two arrays of animals (for example). $array = array( array( 'id' =>
I have a JFrame with null layout and two one character JLabels on the
I have two strings and I would like to mix the characters from each
I have two applications written in Java that communicate with each other using XML
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
How can we split a std::string and a null terminated character array into two
I have two NSMutableArrays, collectables and collectableViews. My app consists of a character moving
I'm having a little problem modifying an array in C. I have two arrays,
I have two arrays one with fake Japanese characters, another with the English alphabet
I have a structure containing character arrays with no any other member functions. I

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.