Solved

shorter form for value=~value; ?

Posted on 2001-06-11
7
182 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

828 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