is it bug?

Alexandr Druzhinin drug2004 at bk.ru
Thu Apr 4 08:45:13 PDT 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 at 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


More information about the Digitalmars-d-learn mailing list