BASIC "sgn" function equivalent
pascal111
judas.the.messiah.111 at gmail.com
Thu Jul 28 14:30:38 UTC 2022
On Thursday, 28 July 2022 at 12:13:31 UTC, Antonio wrote:
> 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
Of-course D has a built in "sgn" function, but I like to do it
with my hands to be sure of code, I'm some doubtful and don't
trust alien works.
More information about the Digitalmars-d-learn
mailing list