Thread overview
is it bug?
Apr 04, 2013
Alexandr Druzhinin
Apr 04, 2013
Ali Çehreli
Apr 04, 2013
Alexandr Druzhinin
Apr 04, 2013
Ali Çehreli
Apr 05, 2013
Alexandr Druzhinin
Apr 11, 2013
Alexandr Druzhinin
Apr 11, 2013
Alexandr Druzhinin
April 04, 2013
on win7 64 bits using dmd 2.062 32 bits this code http://dpaste.dzfl.pl /6cca43b5 failed with assert failure: core.exception.AssertError@std.range(5288): Assertion failure
but on ubuntu 12.04 64 bits, dmd 2.062 64 bit it compiles and works rather well. May be I missed something important with it?
April 04, 2013
On 04/04/2013 06:27 AM, Alexandr Druzhinin wrote:
> on win7 64 bits using dmd 2.062 32 bits this code http://dpaste.dzfl.pl
> /6cca43b5 failed with assert failure:
> core.exception.AssertError@std.range(5288): Assertion failure
> but on ubuntu 12.04 64 bits, dmd 2.062 64 bit it compiles and works
> rather well. May be I missed something important with it?

The problem is reproducible on Linux as well if you compile with -m32.

The following assert fails in range.d:

  assert(start + count * step >= end);

start: 0
count: 83
step: 12.0386
end: 999.2

Even though count * step is seemingly 999.2 as well, due to the inexact nature of floating point calculations the assertion is false.

The problem seems to be in your code because your step calculation ignores a remainder. This works:

    // OLD: step = width / factor;
    step = (width  + factor - 1) / factor;

Ali

April 04, 2013
04.04.2013 21:24, Ali Çehreli пишет:
> On 04/04/2013 06:27 AM, Alexandr Druzhinin wrote:
>> on win7 64 bits using dmd 2.062 32 bits this code http://dpaste.dzfl.pl
>> /6cca43b5 failed with assert failure:
>> core.exception.AssertError@std.range(5288): Assertion failure
>> but on ubuntu 12.04 64 bits, dmd 2.062 64 bit it compiles and works
>> rather well. May be I missed something important with it?
>
> The problem is reproducible on Linux as well if you compile with -m32.
>
> The following assert fails in range.d:
>
>    assert(start + count * step >= end);
>
> start: 0
> count: 83
> step: 12.0386
> end: 999.2
>
> Even though count * step is seemingly 999.2 as well, due to the inexact
> nature of floating point calculations the assertion is false.
>
> The problem seems to be in your code because your step calculation
> ignores a remainder. This works:
>
>      // OLD: step = width / factor;
>      step = (width  + factor - 1) / factor;
>
> Ali
>
that works, thank you very much! but provide some link to some good article that explains my mistake, I didn't realize it clearly
April 04, 2013
On 04/04/2013 08:45 AM, Alexandr Druzhinin wrote:
> 04.04.2013 21:24, Ali Çehreli пишет:

>> The problem seems to be in your code because your step calculation
>> ignores a remainder. This works:
>>
>>      // OLD: step = width / factor;
>>      step = (width  + factor - 1) / factor;
>>
>> Ali
>>
> that works, thank you very much! but provide some link to some good
> article that explains my mistake, I didn't realize it clearly

I was wrong. What I found is just a workaround. Created a bug for iota:

  http://d.puremagic.com/issues/show_bug.cgi?id=9877

The following program fails when compiled with -m32:

import std.range;

void main()
{
    float st = 0.000000000000000;
    float step = 12.038554191589355;
    float en = 999.200012207031250;

    iota(st, en, step);
}

Ali

April 05, 2013
05.04.2013 0:26, Ali Çehreli пишет:
>
> I was wrong. What I found is just a workaround. Created a bug for iota:
>
>    http://d.puremagic.com/issues/show_bug.cgi?id=9877
>
> The following program fails when compiled with -m32:
>
> import std.range;
>
> void main()
> {
>      float st = 0.000000000000000;
>      float step = 12.038554191589355;
>      float en = 999.200012207031250;
>
>      iota(st, en, step);
> }
>
> Ali
>
Thank you, Ali.
will be waiting it will be fixed.
April 11, 2013
05.04.2013 1:26, Ali Çehreli пишет:
>
> I was wrong. What I found is just a workaround. Created a bug for iota:
>
>    http://d.puremagic.com/issues/show_bug.cgi?id=9877
>
> The following program fails when compiled with -m32:
>
> import std.range;
>
> void main()
> {
>      float st = 0.000000000000000;
>      float step = 12.038554191589355;
>      float en = 999.200012207031250;
>
>      iota(st, en, step);
> }
>
> Ali
>
Ali, please, take a look at this http://dpaste.dzfl.pl/44e64eb0
it's code of ctor of iota float point specialization. And it's strange for me, that pastEnd and (start + count * step) have the same value, but give different comparing results.
April 11, 2013
11.04.2013 12:13, Alexandr Druzhinin пишет:
> Ali, please, take a look at this http://dpaste.dzfl.pl/44e64eb0
> it's code of ctor of iota float point specialization. And it's strange
> for me, that pastEnd and (start + count * step) have the same value, but
> give different comparing results.

it fixes bug (I guess) http://dpaste.dzfl.pl/b9577e70