Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how ican CHANGE negative to positive 1

Status
Not open for further replies.

darkdido

Programmer
Nov 23, 2005
8
SD
how ican CHANGE negative to positive
like
9-10=-1
i need without - negative
 
There are, as always in computer software development, a number of ways. The first two off the top of my head are

1. Use the absolute function i.e. abs(-1) returns 1
2. Multiply the result of the subtraction by -1 i.e.
answer = 9 - 10
if answer < 0 then
answer = answer * -1
endif
HTH
 
There is also the unary operator

answer = -answer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top