change a number ( negative and positive)

change a number ( negative and positive)

Postby Silvio.Falconi » Sun Nov 09, 2014 9:12 pm

nNumber:= 100.00

nNegative:= signo(nNumber) return - 100.00 ok
nPositive := signo( nNegative) return allways - 100.00

why ?

the function
FUNC Signo(nValue)
RETURN (IF(nValue>0, -1.0, 1.0))
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: change a number ( negative and positive)

Postby Rick Lipkin » Sun Nov 09, 2014 9:54 pm

Silvo

Try multiplying your return number by -1 for a negative number 100 * -1 = -100

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2618
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: change a number ( negative and positive)

Postby FranciscoA » Sun Nov 09, 2014 10:07 pm

Maybe this idea:
n:=100
MsgInfo( if(n>0,-n,Abs(n)),"was posit, now it's negat" )

n:= -100
MsgInfo( if(n>0,-n,Abs(n)), "was negat, now it's posit" )
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2110
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: change a number ( negative and positive)

Postby Silvio.Falconi » Sun Nov 09, 2014 11:41 pm

Armando,I wish insert "±" on msgcalc()

@ n + nlinea2,ncol6 BUTTON oBtPM PROMPT "±" OF oDlg ;
SIZE 30,25 ;
ACTION (CalcRes( cLastOpe, @nMemo, oGet, oRes, cPict,.t.,"±" ), ;
cLastOpe := "±" ) FONT oFont

on Calcres function I add

elseif cnOpe == "±"
nMemo := if(nval>0,-nval,Abs(nval) )

before let me -100.00 after if I repress the button ± not change it into positive
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: change a number ( negative and positive)

Postby Carlos Mora » Mon Nov 10, 2014 11:31 am

Ciao Silvio,

May be I'm missing sth, but what about, instead of
Code: Select all  Expand view

elseif cnOpe == "±"
   nMemo := if(nval>0,-nval,Abs(nval) )
 


try
Code: Select all  Expand view

elseif cnOpe == "±"
   nMemo := -nval
 

that simpler way should do what you intend, changing number's sign. ¿Isn't it?
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 988
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: change a number ( negative and positive)

Postby Silvio.Falconi » Tue Nov 11, 2014 8:45 am

I saw there is a function on clipper tools 5.3 sign()

http://www.itlnet.net/Programming/Progr ... cdaec.html
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: change a number ( negative and positive)

Postby Silvio.Falconi » Tue Nov 11, 2014 9:04 am

run also to xharbour but return - 1 or +1


Image

I tried

nMemo := IIF( sign(nval)=1,-1*nVal,abs(nVal))

but not run

tried also in this mode
If sign(nval)= 1
nMemo :=-nVal
elseif sign(nval)= -1
nMemo := (nVal*(-1))
endif
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 92 guests