Re: signbit question

2018-03-16 Thread Seb via Digitalmars-d-learn
On Friday, 16 March 2018 at 08:35:58 UTC, Radu wrote: On Friday, 16 March 2018 at 07:00:36 UTC, ashit axar wrote: On Thursday, 15 March 2018 at 17:30:48 UTC, Seb wrote: They generate the same assembly: https://godbolt.org/g/4ohTJx import std.stdio; void main() { writeln("hello"); }

Re: signbit question

2018-03-16 Thread Radu via Digitalmars-d-learn
On Friday, 16 March 2018 at 07:00:36 UTC, ashit axar wrote: On Thursday, 15 March 2018 at 17:30:48 UTC, Seb wrote: They generate the same assembly: https://godbolt.org/g/4ohTJx import std.stdio; void main() { writeln("hello"); } this generate error for dmd there. `writeln` is not

Re: signbit question

2018-03-16 Thread ashit axar via Digitalmars-d-learn
On Thursday, 15 March 2018 at 17:30:48 UTC, Seb wrote: They generate the same assembly: https://godbolt.org/g/4ohTJx import std.stdio; void main() { writeln("hello"); } this generate error for dmd there.

Re: signbit question

2018-03-15 Thread ketmar via Digitalmars-d-learn
Miguel L wrote: as the calculations on f guarantee it cannot be 0 at all. than `f` will become zero very soon. something that "cannot happen" is the most probable thing to happen. otherwise, LGTM.

Re: signbit question

2018-03-15 Thread Dlang User via Digitalmars-d-learn
On 3/15/2018 12:39 PM, Miguel L wrote: On Thursday, 15 March 2018 at 17:31:38 UTC, rumbu wrote: On Thursday, 15 March 2018 at 17:18:08 UTC, Miguel L wrote: On Thursday, 15 March 2018 at 16:31:56 UTC, Stefan Koch wrote: On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: [...]

Re: signbit question

2018-03-15 Thread Miguel L via Digitalmars-d-learn
On Thursday, 15 March 2018 at 17:31:38 UTC, rumbu wrote: On Thursday, 15 March 2018 at 17:18:08 UTC, Miguel L wrote: On Thursday, 15 March 2018 at 16:31:56 UTC, Stefan Koch wrote: On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: [...] integers don't have a sign-bit. since they

Re: signbit question

2018-03-15 Thread rumbu via Digitalmars-d-learn
On Thursday, 15 March 2018 at 17:18:08 UTC, Miguel L wrote: On Thursday, 15 March 2018 at 16:31:56 UTC, Stefan Koch wrote: On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: Why does std.math.signbit only work for floating point types? Is there an analogue function for integer types?

Re: signbit question

2018-03-15 Thread Seb via Digitalmars-d-learn
On Thursday, 15 March 2018 at 16:31:56 UTC, Stefan Koch wrote: On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: Why does std.math.signbit only work for floating point types? Is there an analogue function for integer types? what is the best way to compare the sign of a float with the

Re: signbit question

2018-03-15 Thread Miguel L via Digitalmars-d-learn
On Thursday, 15 March 2018 at 16:31:56 UTC, Stefan Koch wrote: On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: Why does std.math.signbit only work for floating point types? Is there an analogue function for integer types? what is the best way to compare the sign of a float with the

Re: signbit question

2018-03-15 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: Why does std.math.signbit only work for floating point types? Is there an analogue function for integer types? what is the best way to compare the sign of a float with the sign of an integer? Thanks in advance integers don't have a

Re: signbit question

2018-03-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: Why does std.math.signbit only work for floating point types? Integers are stored in an entirely different way, twos-complement instead of having a sign bit. You probably shouldn't be using the sign bit function at all, it is for

Re: signbit question

2018-03-15 Thread Seb via Digitalmars-d-learn
On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: Why does std.math.signbit only work for floating point types? Is there an analogue function for integer types? I guess because for integers you don't need to distinguish between +0.0 and -0.0, so no one bother until now to add it to

signbit question

2018-03-15 Thread Miguel L via Digitalmars-d-learn
Why does std.math.signbit only work for floating point types? Is there an analogue function for integer types? what is the best way to compare the sign of a float with the sign of an integer? Thanks in advance