git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] blame: avoid -lm by not using log().

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 5, 2006, 23:36 UTC
Message-ID
<Pine.LNX.4.63.0603060032410.32270@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7vhd6cechf.fsf_-_@assigned-by-dhcp.cox.net>
Hi,
On Sun, 5 Mar 2006, Junio C Hamano wrote:
> -	max_digits = 1 + log(num_blame_lines+1)/log(10);
> +	for (max_digits = 1, i = 10; i <= num_blame_lines; max_digits++)
> +		i *= 10;

According to my late-night maths skills, these two methods do not do the same thing: if num_blame_lines == 9, the log method assigns 2 to max_digits, but the for loop stops at max_digits == 1. A trivial fix would be to test for i <= num_blame_lines + 1.

Ciao, Dscho

Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 10 in “git-blame: Make the output human readable”
  1. git-blame: Make the output human readableFredrik Kuivinen, Mar 5, 2006
  2. Junio C HamanoMar 5, 2006
  3. Fredrik KuivinenMar 5, 2006
  4. Johannes SchindelinMar 5, 2006
  5. Junio C HamanoMar 5, 2006
  6. Fredrik KuivinenMar 7, 2006
  7. blame: avoid -lm by not using log().Junio C Hamano, Mar 5, 2006
  8. Johannes SchindelinMar 5, 2006
  9. blame and annotate: show localtime with timezone.Junio C Hamano, Mar 5, 2006
  10. Johannes SchindelinMar 5, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.