[Ns-developers] Bug in shadowing.cc

Marcello Caleffi marcello.caleffi at unina.it
Tue Jan 29 00:13:35 PST 2008


Mathieu,
I agree with you.
Anyway, it's really a bug or not?

PS the minimum value for dist variable should be determined basing on  
the underflow value for the log10() function.

Marcello Caleffi

Il giorno 29/gen/08, alle ore 08:02, Mathieu Lacage ha scritto:

> On Mon, 2008-01-28 at 11:58 +0100, Marcello Caleffi wrote:
>> In the function Shadowing::Pr() the avg_db is calculated as
>> -10.0 * pathLossExp_ * log10(dist/dis0)
>> without checking if dist is equal to 0, as happens if the send and
>> the recv node have the same position. If so, an arithmetic exception
>> happens.
>>
>> What about adding a check as the following:
>> if (dist == 0)
>>     dist = 1e-23;
>> before the avg_db computation?
>
> A more useful test would be:
>
> if (dist <= 1e-23)
>     dist = 1e-23;
>
> or:
>
> dist = std::max (dist, 1e-23);
>
>
> i.e., you can't rely on equality testing of double/float entities  
> except
> in a few very rare cases.
>
> Mathieu



More information about the Ns-developers mailing list