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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:27:48+00:00 2026-06-17T05:27:48+00:00

There are two vectors of differing, yet related sizes. The larger is (2 *

  • 0

There are two vectors of differing, yet related sizes. The larger is (2 * RESOLUTION) + INDEX_OFFSET (e.g. 2050) and the smaller is simply RESOLUTION (e.g. 1024). I believe it safe enough to assume that uint16_t can be used to contain the vector index.

Iteration through the larger vector is performed by incrementing resultIndex by 2. During each iteration, an assignment is made to the smaller vector at the index (resultIndex - INDEX_OFFSET) / 2.

Essentially, the code relies on the assumption that, whether INDEX_OFFSET is odd or even, the above division by 2 will always round down, regardless of architecture. For example, if resultIndex is 0 or 1, then 0 is expected, if is it 2 or 3 then 1 is expected, and so on. Is this a safe assumption, within the parameters above?

N.B. I acknowledge the existence of ‘Dividing integer types – Are results predictable?’ but it does not seem to be an exact match.

  • 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-17T05:27:49+00:00Added an answer on June 17, 2026 at 5:27 am

    Yes; this is guaranteed by the language:

    [C++11: 5.6/4]: The binary / operator yields the quotient, and the binary % operator yields the remainder from the division of the first expression by the second. If the second operand of / or % is zero the behavior is undefined. For integral operands the / operator yields the algebraic quotient with any fractional part discarded; if the quotient a/b is representable in the type of the result, (a/b)*b + a%b is equal to a.

    In 3/2, both 3 and 2 are integral operands; the algebraic quotient of this operation is 1.5, and when you discard the fractional part .5, you get 1. This holds for your other examples and, well, all other examples.

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

Sidebar

Related Questions

simply trying to compare two user defined vectors to see if they are equal,
Is there a function to compare two string vectors to return the number of
I have two vectors, v1 and v2 v1 <- c('one', 'two', 'three') v2 <-
I want to create two and three dimensional vectors using a constructor in a
I have read a document that they say: In java there two types of
There are two intents on the receiver side which are called from the same
There are two table s : one is the master and one the detail
There are two lists: List<string> excluded = new List<string>() { .pdf, .jpg }; List<string>
There are two project in which I collaborate, they live in different servers, A
There are two similar questions asked here and here but no adequate answers are

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.