?
Solved

shorter form for value=~value; ?

Posted on 2001-06-11
7
Medium Priority
?
185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 75 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

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…
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 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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

777 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