BASIC "sgn" function equivalent

Adam D Ruppe destructionator at gmail.com
Thu Jul 28 12:49:50 UTC 2022


On Thursday, 28 July 2022 at 12:02:54 UTC, pascal111 wrote:
> 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?

There's no need to do the complication of a template, just do a 
normal function taking a `double`. You can add overloads if you 
want like one taking a `long` and/or `int` but those would cover 
all types that have signs.


More information about the Digitalmars-d-learn mailing list