FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour change a number ( negative and positive)
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
change a number ( negative and positive)
Posted: Sun Nov 09, 2014 09: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 March-April 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
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: change a number ( negative and positive)
Posted: Sun Nov 09, 2014 09:54 PM

Silvo

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

Rick Lipkin

Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: change a number ( negative and positive)
Posted: 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
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: change a number ( negative and positive)
Posted: 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 March-April 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
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: change a number ( negative and positive)
Posted: Mon Nov 10, 2014 11:31 AM
Ciao Silvio,

May be I'm missing sth, but what about, instead of
Code (fw): Select all Collapse
elseif cnOpe == "±"
   nMemo := if(nval>0,-nval,Abs(nval) )


try
Code (fw): Select all Collapse
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"
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: change a number ( negative and positive)
Posted: Tue Nov 11, 2014 08: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 March-April 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
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: change a number ( negative and positive)
Posted: Tue Nov 11, 2014 09:04 AM
run also to xharbour but return - 1 or +1




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 March-April 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

Continue the discussion