On Thursday, 28 July 2022 at 15:38:18 UTC, H. S. Teoh wrote:
On Thu, Jul 28, 2022 at 03:10:19PM +, pascal111 via
Digitalmars-d-learn wrote:
> [...]
[...]
[...]
AFAIK, all D compilers ship with full Phobos source code. On my
installation, it's in
/usr/lib/gcc/x86_64-linux-gnu/11/include
On Thu, Jul 28, 2022 at 03:10:19PM +, pascal111 via Digitalmars-d-learn
wrote:
> On Thursday, 28 July 2022 at 15:03:34 UTC, H. S. Teoh wrote:
> > On Thu, Jul 28, 2022 at 02:30:38PM +, pascal111 via
> > Digitalmars-d-learn wrote: [...]
> > > Of-course D has a built in "sgn" function, but I
On Thursday, 28 July 2022 at 15:03:34 UTC, H. S. Teoh wrote:
Just use the source, Luke! Phobos is open source for a reason.
https://github.com/dlang/phobos/blob/8280b1e7de6cca4dc9a593431591054a5b3aa288/std/math/traits.d#L694
T
:-)
```d
// @@@TODO@@@: make this faster
```
On Thursday, 28 July 2022 at 15:03:34 UTC, H. S. Teoh wrote:
On Thu, Jul 28, 2022 at 02:30:38PM +, pascal111 via
Digitalmars-d-learn wrote: [...]
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.
On Thu, Jul 28, 2022 at 02:30:38PM +, pascal111 via Digitalmars-d-learn
wrote:
[...]
> 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.
Just use the source, Luke! Phobos is open source for a re
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 ca
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
On Thursday, 28 July 2022 at 12:13:31 UTC, Antonio wrote:
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
```d
import std.traits : isFloatingPoint, isIntegral;
int sgn(T)(T x) if (isFloat
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.
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
retu
10 matches
Mail list logo