Nmap Development mailing list archives
Re: Rounding of OS match percentages differs between architectures
From: David Fifield <david () bamsoftware com>
Date: Wed, 19 Nov 2008 18:26:22 -0700
On Wed, Nov 19, 2008 at 07:54:14PM -0500, Michael Pattrick wrote:
On Wed, Nov 19, 2008 at 6:32 PM, David Fifield <david () bamsoftware com> wrote:Nmap currently uses printf("%d%%", (int) (frac * 100)) to show match percentages. Using printf("%.f%%", frac * 100) would remove this problem but would create another, namely that everything 99.5% and above would be rounded to 100%. Anyone have an opinion on this or see a good way to handle it?If I understand the problem properly - you want to strip the decimals, why not just use floor()?
Hey, thanks, that works! I guess I assumed that ((int) d) and floor(d) would have the same result when d is positive. Apparently floor has extra logic to know when its argument is less than but very close to an integer. (To see what I mean by "very close to," run python and type in "0.98". I see "0.97999999999999998" as output.) I wonder if this is really caused by the C library? Can anyone else reproduce the "97% 98%" output from the test program I posted? David Fifield _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- Rounding of OS match percentages differs between architectures David Fifield (Nov 19)
- Message not available
- Re: Rounding of OS match percentages differs between architectures David Fifield (Nov 19)
- Re: Rounding of OS match percentages differs between architectures jah (Nov 19)
- Re: Rounding of OS match percentages differs between architectures Brandon Enright (Nov 19)
- Re: Rounding of OS match percentages differs between architectures Brandon Enright (Nov 19)
- Re: Rounding of OS match percentages differs between architectures sara fink (Nov 23)
- Re: Rounding of OS match percentages differs between architectures Toni Ruottu (Nov 24)
- Re: Rounding of OS match percentages differs between architectures David Fifield (Nov 19)
- Message not available
- Re: Rounding of OS match percentages differs between architectures DePriest, Jason R. (Nov 19)
- Re: Rounding of OS match percentages differs between architectures Michael Pattrick (Nov 19)
- Re: Rounding of OS match percentages differs between architectures David Fifield (Nov 20)