Csound Csound-dev Csound-tekno Search About

sign(x)

Date1999-01-02 14:36
FromJosep M Comajuncosas
Subjectsign(x)
Hi, I´d like to know whitch is the best way to get the sign of a a-rate
variable... I thougth maybe with a conditional (but this forces kr=sr)
or with something like ((asig+abs(asig))/abs(asig))-1. It should return
1 for asig>=0 and -1 for asig<0

Thanks in advance!

Josep M Comajuncosas

Date1999-01-02 16:25
FromErik Spjut
SubjectRe: sign(x)
My best guess is that

asign	divz	asig, abs(asig), 1

is the fastest.


At 3:36 PM +0100 1/2/99, Josep M Comajuncosas wrote:
>Hi, I´d like to know whitch is the best way to get the sign of a a-rate
>variable... I thougth maybe with a conditional (but this forces kr=sr)
>or with something like ((asig+abs(asig))/abs(asig))-1. It should return
>1 for asig>=0 and -1 for asig<0
>
>Thanks in advance!
>
>Josep M Comajuncosas


-------------------------------------------------------------------------------
Erik Spjut (spyoot, rhymes with cute) - Associate Professor of Engineering
and  Associate Director for Engineering Computing,  Center for Design Education
Harvey Mudd College, Claremont, CA 91711-5990  USA
Erik_Spjut@hmc.edu      Ph & Voice mail (909) 607-3890      Fax (909) 621-8967