Solved

shorter form for value=~value; ?

Posted on 2001-06-11
7
178 Views
Last Modified: 2010-04-02
hi,
is there a shorter form for value=~value; or value^=0xff; like i++; ?
0
Comment
Question by:rosche777
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 4

Expert Comment

by:captainkirk
Comment Utility
don't believe so...
0
 
LVL 1

Expert Comment

by:ua1zcl
Comment Utility
Seems no, because you wish to modify a value.
In some function it looks shorter:
int func(int value);

func(~value);

But value stay unchanged.

0
 
LVL 2

Accepted Solution

by:
joe_h earned 25 total points
Comment Utility
how about:

#define NOT(a) ((a)=~(a))
...
NOT(value)
...


however, be careful about the legibility of your code, since the value of the parameter is modified.

Joe_h
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:rosche777
Comment Utility
hmm.. the value must change..
a syntax like value~~; doesn't exist? :(
0
 
LVL 4

Expert Comment

by:captainkirk
Comment Utility
Only the increment and decrement operators have syntax like that - the only choices I know of are macros, function calls, and the form you posted - value ~= value.
0
 
LVL 2

Expert Comment

by:joe_h
Comment Utility
Nope.
0
 

Author Comment

by:rosche777
Comment Utility
oke thx
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now