Solved

shorter form for value=~value; ?

Posted on 2001-06-11
7
179 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

895 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

17 Experts available now in Live!

Get 1:1 Help Now