John Beckett wrote:
> Bram Moolenaar wrote: > >> g and G omit superfluos zeroes, as well as the decimal point: > >> > >> double n = 12; > >> printf("%g\n", n); // prints 12 > >> printf("%#g\n", n); // prints 12.0000 > > > > Vim is already using %g. For me the results are different. > > In Vim, the code in vim_snprintf() (in message.c) replaces 'g' with > 'f' for a small value like 12, so Vim does not give the result quoted > above. However, "standard" printf should do what I said (see [1]). I forgot about that. I'll have to look into it again. > I am one of those who are inclined to NOT complicate the Vim source by > attending to details of handling floating point, so I would live with > the current situation. However, it did occur to me that you might > contemplate whether a config build option could specify if the native > snprintf() should be used. Then if someone wants "standard" printf, > they could build Vim so vim_snprintf() calls the version supplied by > their library. We can't use the native snprintf() directly, because it may crash Vim. Instead we use a wrapper, but still rely on the library .*printf functions to do the actual Float to String conversion. I also want to minimize configure options, because the behavior should be predictable. Esp. for binaries included with a distribution. > Or, the code in vim_snprintf() could be made a little more complex by > NOT replacing 'g' with 'f'. I'll have a go at that if you like (needs > a little care to be sure we won't overflow the tmp buffer). I added that code for a reason. But I have to be careful not to depend on the FreeBSD specific implementation. -- How To Keep A Healthy Level Of Insanity: 8. Don't use any punctuation marks. /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---