Hello Bacula developers,

I have a question regarding a Bacula bsnprintf library function. Is
bsnprintf supposed to work with a format: "%.2f"? If so, I found a strange
behavior or a bug. If I use above format with double type variable set to
1.05 I get a following result "1.50". The same for any variable in range
from 1.01 (the result is "1.10" up to 1.09 (the result is "1.90").

Here is example file bsntest.c:

#include "stdio.h"
#include "sys/types.h"

int       bsnprintf              (char *str, int32_t size, const char
*format, ...);

int main (void){

  char buffer[20];
  double variable = 1.05;

  bsnprintf(buffer,20,"%.2f",variable);
  printf ("libc:%.2f bacula:%s\n",variable,buffer);
  return 0;
}

You can compile it with: g++ -o bsntest bsntest.c -lbac and the result is:
$ ./bsn
libc:1.05 bacula:1.50

What do you think?

best regards
-- 
Radosław Korzeniewski
rados...@korzeniewski.net
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Bacula-devel mailing list
Bacula-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-devel

Reply via email to