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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:55:01+00:00 2026-05-24T03:55:01+00:00

If you have 128 + 7 – i (where i is declared to be

  • 0

If you have “128 + 7 – i” (where i is declared to be an integer variable), is it a constant expression? Why or why not?

  • 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-24T03:55:02+00:00Added an answer on May 24, 2026 at 3:55 am

    This depends on where i is declared, and whether the compiler can figure out, if there is any chance it can get changed at runtime.

    For example, if your code looked like this:

    ...
    int i = 3;
    int x = 128 + 7 - i;
    ...
    

    the compiler could figure out, that there is no way i could change before it was used in your expression. In that case, it could be inlined as a constant expression at compile time.

    If, however, it were like this:

    -(void) doSomething:(int) i {
        ...
        int x = 128 + 7 - i;
        ...
    }
    

    The value could change at runtime, depending on the method parameter, in which case it could not be constant for the compiler.

    Be aware, that whether or not the compiler can do optimizations like the one described above depends on the compiler’s settings. For example, in debug builds it would most certainly not do so.

    EDIT: As correctly pointed out by Rudy Velthuis in the comments, I was a little too fast in my answer. In fact, the first example is not really a constant expression, which the compiler will (very explicitly indeed) tell you. I did not take into account that constant expression is a fixed term with a clear definition (e. g. see Java Language Spec here, don’t have a C version handy right now). Instead I confused it with a compiler optimization technique which through data flow analysis inside a method would allow it to replace the aforementioned code with a constant value.

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

Sidebar

Related Questions

I have a 128-byte (1024-bit) modulus (in a byte array format) and my exponent
I have an array of ints like this: [32,128,1024,2048,4096] Given a specific value, I
I have an array result that contains values from 0-255. I originally declared it
I have a 128-bit number in hexadecimal stored in a string (from md5, security
I have a function declared as: int myFunction(const float** ppArr, const int n, const
I have a 128-bit string, and my supervisor has asked me to represent those
I have a problem with ecrypting data using AES-128/ecb/PKCS5Padding+base64. I am using the following
I have a function in a managed C++ DLL that needs to pass 128
I have some data in the following format: 1298501934.311 42.048 1298501934.311 60.096 1298501934.311 64.128
I have a code that goes something like: $cipher_alg = MCRYPT_RIJNDAEL_128; $decrypted_string = mcrypt_decrypt($cipher_alg,

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.