BASIC "sgn" function equivalent

pascal111 judas.the.messiah.111 at gmail.com
Thu Jul 28 12:02:54 UTC 2022


I'm making an equivalent of "sgn" function of BASIC language, and 
I used "(T)" in its definition, but the function can receive 
wrong data by passing string data to it, how we can solve it?

int sgn(T)(T x)
{

     if(x<0)
         return -1;
     else if(x>0)
         return 1;
     else
         return 0;

}


More information about the Digitalmars-d-learn mailing list