Solved

shorter form for value=~value; ?

Posted on 2001-06-11
7
180 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
ID: 6177399
don't believe so...
0
 
LVL 1

Expert Comment

by:ua1zcl
ID: 6177435
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
ID: 6177526
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

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

Expert Comment

by:captainkirk
ID: 6177545
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
ID: 6177551
Nope.
0
 

Author Comment

by:rosche777
ID: 6177598
oke thx
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 clear a vector as well as how to detect empty vectors in C++.

776 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