BASIC "sgn" function equivalent
Antonio
antonio at abrevia.net
Thu Jul 28 12:13:31 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?
Use isFloating!T and isIntegral!T traits.
The standard library **sng** function is a good example:
https://dlang.org/library/std/math/traits/sgn.html
More information about the Digitalmars-d-learn
mailing list