The value of field returns a number.
How can I transform this to the negative value?
If the value of the field is 2 I want to transform it to -2
How can I do this in @formulas?
The value of field returns a number.
How can I transform this to the negative value?
If the value of the field is 2 I want to transform it to -2
How can I do this in @formulas?
Subject: transform a number to negative value
negValue := @If(currentValue = “”; 0; 0 - @Abs(currentValue))
Subject: transform a number to negative value
FIELD Numberfield := -Numberfield;
Try:
someNumber := 5;
@If( -5 = -someNumber ; @Prompt([Ok];“”;“I can’t believe it was this easy! Doh!”) ; “” )
Subject: RE: transform a number to negative value
What, precisely, is -“”? And why do you assume that the value is not already negated before you get there?
Subject: RE: transform a number to negative value
The dash is the negative unary operator, just like a plus is the positive unary operator.
You can say
3 - 2
where the dash is the subtraction operator. But you can also say:
3 - -2
where the dash is both a subtraction and unary operators.
I didn’t presume that the starting value is not a negative value. I was proceeding on the stated goal of transforming a number to its negative value. The negative value of a negative number is a positive value. I see no criteria that indicates the outcome should be a negative value regardless of the sign. However, I can do that too:
someNumber := -5;
@If( -5 = -@ABS(someNumber) ; @Prompt([Ok];“”;“I can’t believe it was nearly as easy as the last one! Doh!” ) ; “”)