To convert a positive number X into a negative number (-X) is called "negating"?

Negate [verb] (used without object) - To be negative; bring or cause negative.

I’m looking for a programming term used to mean “a way to convert a positive number into its negative form.”

For example:

  1. I “negate” that to -10.
  2. After negation: -23.
    -15. Negate it. 15.
result = -result; //Negate the variable "result".

etc.

It’s comparable to how I think I use the word NOT, or !, in daily usage.

Example usage of NOT:

boolean test = false; //(!test = true.)
!1; //Value is 0 or 0x0

Example usage of NOT in sentences:

“See this flag? Use the NOT value of the flag.”
“Try NOTting the value and NOR it with the result.”
“NOT the XOR value from the base.”

Is the word “negate” optimal for the usage of such scenario? Thanks in advance.

Depending on whether the search engine in question allows it (I believe that google does) “Logical Not” might work. If that fails, negation may or may not work. It really depends on what you’re trying to find out in a given situation and where your searches are being executed, as well as how the writers of a given site/paper used the term.

Optimal? … I guess. At the very least it’s perfectly fine.

Perfect. This is enough for me to continue my documentation for my work. :smiley:

Don’t forget bitwise negation with ~
:slight_smile:

Negation, in computer science, is used to refer to NOT operations, like:



boolean negateFlag(boolean flag)
{
    return !flag;
}


Obtaining the negative of a value is finding the inverse of said value. From http://en.wikipedia.org/wiki/Inverse_function:

As such, a -1 is not necessarily the negation of 1, as it is not a boolean true/false statement. In programming, sometimes integer values are used in lieu of boolean values, but generally they are either part of an evaluation that returns a boolean result, like if(x >= y), or, when used to act as a boolean flag, the compiler (generally) only checks if the value is zero (0) for FALSE and any other value for TRUE.

For the compiler, if the value is any number other than 0 (FALSE), and I want a word used as a verb, a word which it describes an action that allows me to do the following math:

f(x) = -x

Would I use the word “inverse”?

I read the very last reply, and by that, I felt the word “negate” may confuse readers of my documentation. As in, it’s now more unreliable than I expected at first.

Inverse of x is 1/x;

IIRC Inverse just means the switching of positions of the head and tail. I.e, since (x == x/1) thus the inverse is therefore 1/x.

When talking about mathematics like this, it’s best to talk in mathematics, i.e, provide examples instead of relying on pure literature.

I mean, the function is defined as “f(x) = -x”, you can’t define it any better than that. In words it’d be something like for every number x inserted into the function f you would get -x or something silly like that.

For x = !x negation or logical inverse is correct.
For x = -x Algebraic Negation or Additive Inverse is correct.

However, if you’re worried that your readers will get confused by the use of ‘Negation’ or ‘Inverse’ in these cases, then you’re probably focusing on the wrong thing. If you’re still worried, select whichever word you like best, define it as succinctly as you can, then proceed to write the rest of your documentation and your language.

Is Multiplicative Inverse. Which is, honestly, the more ‘usual’ use of the term ‘inverse’ in mathematics. At least, I know that I’ve had math teachers correct me when I use x = - x to define ‘inverse’ as a general term. However, if you say ‘inverse: x = -x’ in a definition, I doubt that there would be much confusion, especially if there’s any sort of context where it’s used.

Natural language is by nature ambitious. Give a one liner in English and give the math form and move on.

Better yet, combine the two and punch the reader in the face with a math pun.

Alright, everything’s clear now. Thanks, everyone!