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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:20:07+00:00 2026-05-14T03:20:07+00:00

Incase of pointer arithmetic, are the integers automatically converted to their signed variants? If

  • 0

Incase of pointer arithmetic, are the integers automatically converted to their signed variants? If yes, why?

Suppose I do

int *pointer; 
int *pointerdiff;
unsigned int uiVal = -1;

pointerdiff = pointer + uiVal // Pointer will contain valid address here.

where pointer is a pointer to int and uiVal is initialized to -1, then I find that the address in pointers get decremented by 4. Why is the unsigned value of -1 not considered here?

  • 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-14T03:20:07+00:00Added an answer on May 14, 2026 at 3:20 am

    It looks like your pointer is overflowing.

    Let’s do some maths. Say you’re on a 32-bit machine, and your pointer is initialised to 0x 12 34 56 78. We then initialise an unsigned int variable to -1, which is 0x FF FF FF FF. Because it’s an unsigned integer, the -1 is overflowing and actually represents 4 294 967 295.

    Your pointer is to an integer (int*), so each increment actually increments the address by sizeof int, which is 4 on a standard x86 machine. So we’re actually adding 0x 03 FF FF FF FC (which is 0x FF FF FF FF * 4).

    Now let’s add the two together.

      0x 00 12 34 56 78
    + 0x 03 FF FF FF FC
    -------------------
      0x 04 12 34 56 74
    

    Of course, this overflows, because we now have a 40-bit value, and a pointer is 32 bits and can only hold that much information. We therefore lose the 04 at the start. This results in 0x 12 34 56 74, which is 0x 12 34 56 78 - 4.

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

Sidebar

Related Questions

My understanding of the MVC is as follows (incase it's horribly wrong, I am
EDIT: I suppose I should clarify, in case it matters. I am on a
Let's say I have some code that does some floating point arithmetic and stores
I am testing a function pointer called ErrorLoggingMethod in a C# DLL to prevent
In my C++ main function, for example, if I had a pointer to a
In this sentence: myCommand.ExecuteReader(CommandBehavior.CloseConnection) does it close connection in case of exception?
First of all (in case this is important) I'm using ActiveState's Perl (v5.8.7 built
I'd like to do something like this raiserror(concat('Error in case @isFishy =', @isFishy, '
Is there any difference between a volatile Object reference and AtomicReference in case I
I'm writing an utility ( http://reg2run.sf.net ) which in case execution without arguments works

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.