Questions tagged [negation]

Negation is the logic operation that inverses a value, also seen as a NOT operation. Functions in specific languages may operate with negation to specific uses. For questions specific to the use of complement patterns in regular expressions, use [regex-negation] instead.

Negation is the logic operation that inverses a value, also seen as a NOT operation. Negation may be implemented by specific languages to provide functions capable of operating with values for specific uses.

Read also the wikipedia article on Negation.

248 questions
3
votes
2 answers

How to negate class selector in Cytoscape.js?

I want to select all elements that do not have the class "myclass". How can I do that in Cytoscape.js? According to http://js.cytoscape.org/#selectors/data, "[^name] Matches elements if the specified data attribute is not defined", however a class…
Konrad Höffner
  • 11,100
  • 16
  • 60
  • 118
3
votes
3 answers

Why printf ("%d", ~a); displays -4 when a is equal to 3?

Running the following program display -4 while 252 is expected: unsigned char a=3; printf ("%d", ~a); Why this code doesn't display 252? I also tested the folowings according to the proposed answer: printf ("%u", ~a); displays: 4294967292 printf…
Mr Robot
  • 1,037
  • 9
  • 17
3
votes
1 answer

re.sub with exception or condition

I want to sub use re.sub to substitute all the words with parentheses but not the word (k), I want to use some negation conditions but it seems not working to my example. I've tried \((?
MMM
  • 425
  • 1
  • 7
  • 24
3
votes
0 answers

How to replace all non-supplementary chars, but leave all supplementary as is?

I have a problem with Java Regex applied on supplementary chars String x = new StringBuilder().appendCodePoint(0x10001).toString(); // x == "" (char['\uD800', '\uDC01']) - ok String y = x.replaceAll("[\\x{10000}-\\x{10010}]", "*"); // y == "*"…
nEraquasAr
  • 191
  • 1
  • 4
3
votes
2 answers

r exclude sentences with keywords

I am dealing with sentences that are as follows Has no anorexia She denies anorexia Has anorexia Positive for Anorexia My goal is to exclude sentences that have words like denies, denied, no and retain only the positive indication…
Sundown Brownbear
  • 491
  • 1
  • 5
  • 15
3
votes
1 answer

perl6 negating user-defined caracter class

I am trying to ignore all lines that has a quotation mark in it, somehow it is kind of onfusing: > my $y='\"\""'; \"\"" > so $y ~~ m/<-[\"]>/ True # $y has a " mark, so I want it to be False > $y ~~ m/<-[\"]>/ 「\」 > $y ~~…
lisprogtor
  • 5,677
  • 11
  • 17
3
votes
5 answers

What is the difference between ~~x and !!x in C?

I am trying to check if any bit of an int x equals to 1, and the answer is !!x. I googled a bit and didn't find anything about why this is correct. So say if I have a number x is 1010. What would !x be? What is the different between !x and ~x?
Anna
  • 443
  • 9
  • 29
3
votes
5 answers

What is the meaning of `!!empty?`?

ActiveSupport extends Object with an instance method blank?: class Object def blank? respond_to?(:empty?) ? !!empty? : !self end end Could !!empty? be written as empty? instead? Is this a stylistic choice so that it reads easily as a method…
eeeeeean
  • 1,774
  • 1
  • 17
  • 31
3
votes
6 answers

Multiplication function with recursion in Python

I need to write the function mult( n, m ) that should output the product of the two integers n and m. I am limited to using addition/subtraction/negation operators, along with recursion. This is what I have so far: def mult( n, m ): if m ==…
Benjamin Brooks
  • 195
  • 3
  • 6
  • 14
3
votes
1 answer

java regex: negation of a match

Although I read a large number of posts on the topic (in particular using lookarounds), I haven't understood if this more general case can be solved using regular expressions. setup: 1) an input regex is passed in 2) the input regex is embedded in…
Marco Boi
  • 49
  • 1
  • 4
3
votes
1 answer

Cypher - How is negation handled?

I have been trying to understand how Cypher corresponds to graph database theory. In particular I had in mind "Query Languages for Graph Databases by Peter T.Wood" (http://users.dcc.uchile.cl/~pbarcelo/wood.pdf). I imagine that it corresponds to…
Michael Anslow
  • 397
  • 3
  • 12
3
votes
1 answer

Why does `not (some-width: Xem)` media query never fire?

I'm trying to negate the max-device-width media query (the reason for this is I don't won't both (max-device-width: X) and (min-device-width: X) to fire if the device has precisely that width). Unfortunately, the not (min-or-max-some-width: X) media…
Septagram
  • 9,425
  • 13
  • 50
  • 81
3
votes
1 answer

Excluding certain property values in inline query

I use the three values (=pages) A, B, C for the property is of type. Some pages have exactly one value for is of type, some pages have all three values. I want to #ask for pages that are of type A without being of type B and C. I tried the following…
unor
  • 92,415
  • 26
  • 211
  • 360
3
votes
3 answers

Negation operator and comparison

Lets take some code samples: ! 4 > 0; From C++ standard we know, that negation will be done first, than comparison. But if we expand this example a little: #include class Test { public: bool operator!() const { …
Kamil Klimek
  • 12,884
  • 2
  • 43
  • 58
2
votes
0 answers

How to get the Corresponding Negation Terms used for a Set of Detected Negated Lexicons in NegSpacy?

I am working on a project with a clinical dataset. So far, I was able to detect all the diagnoses and whether they are negated or not. But, what I really like to get as well, is the negation term used to detect each negated lexicon. For…