[SP-pm] Alguém tem uma forma melhor de compara números reais ?
Alexei Znamensky
russoz at gmail.com
Mon May 31 12:33:16 PDT 2010
tente
POSIX::modf
2010/5/31 <thiagoglauco em ticursos.net>
> Eu tenho o seguinte algoritmo para comparar números reais. Alguém tem uma
> forma melhor, menor, mais legível ou um módulo?
>
> # sao_iguais(NUM1, NUM2, PRECISAO) : Retorna "true" se os valores reais
> forem #iguais dentro da precisão determinada.
>
> sub sao_iguais {
> my ($num1, $num2, $precisao) = @_;
> return sprintf("%.${precisao}f", $num1) eq sprintf("%.${precisao}f",
> $num2);}
> _______________________________________________
> SaoPaulo-pm mailing list
> SaoPaulo-pm em pm.org
> http://mail.pm.org/mailman/listinfo/saopaulo-pm
>
--
Alexei Znamensky [russoz_gmail_com] [russoz.wordpress.com] [
www.flickr.com/photos/alexeiz]
"Though we live in trying times, we're the ones who have to try"
-------------- Pr�xima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://mail.pm.org/pipermail/saopaulo-pm/attachments/20100531/06ddabc4/attachment.html>
More information about the SaoPaulo-pm
mailing list