[PATCH] fpcmp fix (wrt sqlite3)

Daniel Dunbar daniel at zuster.org
Thu Apr 4 14:25:53 PDT 2013


Hey Renato,

I'm afraid of fpcmp the way it is written, so I'm hoping you did a fair
amount of testing on it. :)

I think it would be cleaner to just change BackupNumber so that it is
willing to backup one character behind the initial point, and I don't think
there is any reason to require that character to be a space. Given the way
the rest of it works it seems like this test case might as well pass:
--
ddunbar at ozzy-2:tmp$ echo "1.234b" > a
ddunbar at ozzy-2:tmp$ echo "1.2341" > b
ddunbar at ozzy-2:tmp$ fpcmp -a=.1 a b
fpcmp: FP Comparison failed, not a numeric difference between 'b' and '1'
--

 - Daniel


On Wed, Apr 3, 2013 at 11:07 AM, Renato Golin <renato.golin at linaro.org>wrote:

> As reported in this bug:
>
> http://llvm.org/bugs/show_bug.cgi?id=15620
>
> fpcmp gets it wrong when comparing floating point numbers.
>
> I found that it happens when comparing numbers with different number of
> digits, ex:
>
> 257359.326881721
> 257359.32688172
>
> when fpcmp would compare the number with highest precision with the next
> one of the low precision.
>
> The attached patch works around this by rolling back one byte if the
> difference is in a space AND the previous one is a number. Since only one
> of the numbers can be at the space (the shorter one), I only roll back one
> the shorter one.
>
> This patch fixes sqlite3 on ARM and will probably fix on TILE-Gx, too.
>
> Please review.
>
> Thanks,
> --renato
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130404/36410bcb/attachment.html>


More information about the llvm-commits mailing list