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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:11:17+00:00 2026-05-12T13:11:17+00:00

As an exercise, I’d like to write a macro which tells me if an

  • 0

As an exercise, I’d like to write a macro which tells me if an integer variable is signed. This is what I have so far and I get the results I expect if I try this on a char variable with gcc -fsigned-char or -funsigned-char.

#define ISVARSIGNED(V) (V = -1, (V < 0) ? 1 : 0) 

Is this portable? Is there a way to do this without destroying the value of the variable?

  • 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-12T13:11:17+00:00Added an answer on May 12, 2026 at 1:11 pm
    #define ISVARSIGNED(V)  ((V)<0 || (-V)<0 || (V-1)<0)
    

    doesn’t change the value of V. The third test handles the case where V == 0.

    On my compiler (gcc/cygwin) this works for int and long but not for char or short.

    #define ISVARSIGNED(V) ((V)-1<0 || -(V)-1<0)
    

    also does the job in two tests.

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

Sidebar

Related Questions

I have this small exercise that I am trying to finish, but I get
I got this exercise at uni: Write a program that declares a shared integer
This is an academic exercise, I'm new to Reactive Extensions and trying to get
As an exercise I want to have a menu bar which is disabled until
For a class exercise on game trees , I have to write code that
The exercise in this tutorial says: Generate a 10 x 3 array of random
I have the exercise with following code int FindFirstSet(unsigned BitMap, unsigned start) { unsigned
As part of an exercise, am implementing an ArrayList which will support Enumerations. Following
Exercise: There's too much repetition in this file. Use strings, formats, and escapes to
Exercise 14.16-17 in Thompson asks me to add the operations of multiplication and (integer)

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.