Query: strpct
OS: netbsd
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
STRPCT(3) BSD Library Functions Manual STRPCT(3)NAMEstrpct, strspct -- decimal percent formattersLIBRARYSystem Utilities Library (libutil, -lutil)SYNOPSIS#include <util.h> char * strpct(char *buf, size_t bufsiz, uintmax_t numerator, uintmax_t denominator, size_t precision); char * strspct(char *buf, size_t bufsiz, intmax_t numerator, intmax_t denominator, size_t precision);DESCRIPTIONThe strpct() function formats the fraction represented by numerator and denominator into a percentage representation with given number of digits of precision without using floating point arithmetic.RETURN VALUESstrpct() and strspct() always return a pointer to a NUL-terminated (unless buflen is 0) formatted string which is placed in buf and is up to buflen characters. If there was an overflow, the formatted string will reflect that precision loss.EXAMPLESstrpct(buf, buflen, 1, 16, 3); => "6.250" strpct(buf, buflen, 1, 2, 0); => "50"HISTORYstrpct() was originally implemented in csh(1) for NetBSD 1.3. It printed into a static buffer, was not locale aware, handled unsigned long numbers, and printed a ``%'' at the end of the number. Other programs such as df(1) and time(1) started using it. strpct() and strspct() appeared separately in libutil for NetBSD 6.0.AUTHORSErik E. Fair <fair@netbsd.org>BSDJanuary 7, 2012 BSD
Related Man Pages |
---|
opendisk(3) - netbsd |
snprintb(3) - netbsd |
snprintb_m(3) - netbsd |
sockaddr_snprintf(3) - netbsd |
upscli_sendline(3) - opensolaris |
Similar Topics in the Unix Linux Community |
---|
BSD Release: NetBSD 4.0.1 |