Re: What is a concise way to test if floating point value is integral?

2013-08-29 Thread Simen Kjaeraas
On 2013-08-29, 10:25, Jonathan M Davis wrote: On Thursday, August 29, 2013 10:07:31 Paul Jurczak wrote: On Thursday, 29 August 2013 at 07:51:40 UTC, Jonathan M Davis wrote: [..] > as any integral value in a float will fit in an > int. [..] Will it? Most of them will not fit Sure, they will

Re: What is a concise way to test if floating point value is integral?

2013-08-29 Thread JS
On Thursday, 29 August 2013 at 08:58:02 UTC, Paul Jurczak wrote: On Thursday, 29 August 2013 at 08:26:11 UTC, Jonathan M Davis wrote: On Thursday, August 29, 2013 10:07:31 Paul Jurczak wrote: On Thursday, 29 August 2013 at 07:51:40 UTC, Jonathan M Davis wrote: [..] > as any integral value in a

Re: What is a concise way to test if floating point value is integral?

2013-08-29 Thread anonymous
On Thursday, 29 August 2013 at 08:26:11 UTC, Jonathan M Davis wrote: On Thursday, August 29, 2013 10:07:31 Paul Jurczak wrote: On Thursday, 29 August 2013 at 07:51:40 UTC, Jonathan M Davis wrote: [..] > as any integral value in a float will fit in an > int. [..] Will it? Most of them will not

Re: What is a concise way to test if floating point value is integral?

2013-08-29 Thread Paul Jurczak
On Thursday, 29 August 2013 at 08:26:11 UTC, Jonathan M Davis wrote: On Thursday, August 29, 2013 10:07:31 Paul Jurczak wrote: On Thursday, 29 August 2013 at 07:51:40 UTC, Jonathan M Davis wrote: [..] > as any integral value in a float will fit in an > int. [..] Will it? Most of them will not

Re: What is a concise way to test if floating point value is integral?

2013-08-29 Thread Jonathan M Davis
On Thursday, August 29, 2013 10:07:31 Paul Jurczak wrote: > On Thursday, 29 August 2013 at 07:51:40 UTC, Jonathan M Davis > wrote: > [..] > > > as any integral value in a float will fit in an > > int. > > [..] > > Will it? Most of them will not fit Sure, they will. float has 32 bits, just like

Re: What is a concise way to test if floating point value is integral?

2013-08-29 Thread Paul Jurczak
On Thursday, 29 August 2013 at 07:51:40 UTC, Jonathan M Davis wrote: [..] as any integral value in a float will fit in an int. [..] Will it? Most of them will not fit, but cast to int produces nonsensical value anyway as in this example: cast(int)float.max With to!int you get a proper warn

Re: What is a concise way to test if floating point value is integral?

2013-08-29 Thread Jonathan M Davis
On Thursday, August 29, 2013 08:50:47 Paul Jurczak wrote: > On Thursday, 29 August 2013 at 06:23:18 UTC, Jonathan M Davis > > wrote: > > On Thursday, August 29, 2013 07:47:16 Paul Jurczak wrote: > >> I'm writing this rather ugly: > >> > >> sqrt(cast(float)D) != round(sqrt(cast(float)D) > >> > >>

Re: What is a concise way to test if floating point value is integral?

2013-08-28 Thread Paul Jurczak
On Thursday, 29 August 2013 at 06:23:18 UTC, Jonathan M Davis wrote: On Thursday, August 29, 2013 07:47:16 Paul Jurczak wrote: I'm writing this rather ugly: sqrt(cast(float)D) != round(sqrt(cast(float)D) line and I'm looking for more concise notation without introducing a meaningless variable

Re: What is a concise way to test if floating point value is integral?

2013-08-28 Thread Jonathan M Davis
On Thursday, August 29, 2013 07:47:16 Paul Jurczak wrote: > I'm writing this rather ugly: > > sqrt(cast(float)D) != round(sqrt(cast(float)D) > > line and I'm looking for more concise notation without > introducing a meaningless variable to hold expression being > tested. Is there an equivalent of

Re: What is a concise way to test if floating point value is integral?

2013-08-28 Thread Paul Jurczak
On Thursday, 29 August 2013 at 05:47:43 UTC, Paul Jurczak wrote: I'm writing this rather ugly: sqrt(cast(float)D) != round(sqrt(cast(float)D) line and I'm looking for more concise notation without introducing a meaningless variable to hold expression being tested. Is there an equivalent of st

What is a concise way to test if floating point value is integral?

2013-08-28 Thread Paul Jurczak
I'm writing this rather ugly: sqrt(cast(float)D) != round(sqrt(cast(float)D) line and I'm looking for more concise notation without introducing a meaningless variable to hold expression being tested. Is there an equivalent of std.math.trunc(), which would return fractional portion instead, ma