humanize_number.3 (129677) | humanize_number.3 (129730) |
---|---|
1.\" $NetBSD: humanize_number.3,v 1.4 2003/04/16 13:34:37 wiz Exp $ | 1.\" $NetBSD: humanize_number.3,v 1.4 2003/04/16 13:34:37 wiz Exp $ |
2.\" $FreeBSD: head/lib/libutil/humanize_number.3 129677 2004-05-24 22:19:27Z pjd $ | 2.\" $FreeBSD: head/lib/libutil/humanize_number.3 129730 2004-05-25 18:53:54Z trhodes $ |
3.\" 4.\" Copyright (c) 1999, 2002 The NetBSD Foundation, Inc. 5.\" All rights reserved. 6.\" 7.\" This code is derived from software contributed to The NetBSD Foundation 8.\" by Luke Mewburn and by Tomas Svensson. 9.\" 10.\" Redistribution and use in source and binary forms, with or without --- 26 unchanged lines hidden (view full) --- 37.\" 38.Dd May 25, 2004 39.Dt HUMANIZE_NUMBER 3 40.Os 41.Sh NAME 42.Nm humanize_number 43.Nd format a number into a human readable form 44.Sh SYNOPSIS | 3.\" 4.\" Copyright (c) 1999, 2002 The NetBSD Foundation, Inc. 5.\" All rights reserved. 6.\" 7.\" This code is derived from software contributed to The NetBSD Foundation 8.\" by Luke Mewburn and by Tomas Svensson. 9.\" 10.\" Redistribution and use in source and binary forms, with or without --- 26 unchanged lines hidden (view full) --- 37.\" 38.Dd May 25, 2004 39.Dt HUMANIZE_NUMBER 3 40.Os 41.Sh NAME 42.Nm humanize_number 43.Nd format a number into a human readable form 44.Sh SYNOPSIS |
45.In util.h | 45.In libutil.h |
46.Ft int 47.Fn humanize_number "char *buf" "size_t len" "int64_t number" "const char *suffix" "int scale" "int flags" 48.Sh DESCRIPTION 49The 50.Fn humanize_number 51function formats the signed 64 bit quantity given in 52.Fa number 53into --- 23 unchanged lines hidden (view full) --- 77.It k kilo 1024 78.It M mega 1048576 79.It G giga 1073741824 80.It T tera 1099511627776 81.It P peta 1125899906842624 82.It E exa 1152921504606846976 83.El 84.Pp | 46.Ft int 47.Fn humanize_number "char *buf" "size_t len" "int64_t number" "const char *suffix" "int scale" "int flags" 48.Sh DESCRIPTION 49The 50.Fn humanize_number 51function formats the signed 64 bit quantity given in 52.Fa number 53into --- 23 unchanged lines hidden (view full) --- 77.It k kilo 1024 78.It M mega 1048576 79.It G giga 1073741824 80.It T tera 1099511627776 81.It P peta 1125899906842624 82.It E exa 1152921504606846976 83.El 84.Pp |
85The |
|
85.Fa len | 86.Fa len |
86must be at least 4 plus the length of | 87argument must be at least 4 plus the length of |
87.Fa suffix , 88in order to ensure a useful result is generated into 89.Fa buffer . 90To use a specific prefix, specify this as 91.Fa scale 92(Multiplier = 1024 ^ scale). 93This can not be combined with any of the 94.Fa scale --- 22 unchanged lines hidden (view full) --- 117.It Dv HN_B 118Use 'B' (bytes) as prefix if the original result does not have a prefix. 119.It Dv HN_DIVISOR_1000 120Divide 121.Fa number 122with 1000 instead of 1024. 123.El 124.Sh RETURN VALUES | 88.Fa suffix , 89in order to ensure a useful result is generated into 90.Fa buffer . 91To use a specific prefix, specify this as 92.Fa scale 93(Multiplier = 1024 ^ scale). 94This can not be combined with any of the 95.Fa scale --- 22 unchanged lines hidden (view full) --- 118.It Dv HN_B 119Use 'B' (bytes) as prefix if the original result does not have a prefix. 120.It Dv HN_DIVISOR_1000 121Divide 122.Fa number 123with 1000 instead of 1024. 124.El 125.Sh RETURN VALUES |
126The |
|
125.Fn humanize_number | 127.Fn humanize_number |
126returns the number of characters stored in | 128function returns the number of characters stored in |
127.Fa buffer 128(excluding the terminating NUL) upon success, or \-1 upon failure. 129If 130.Dv HN_GETSCALE 131is specified, the prefix index number will be returned instead. 132.Sh SEE ALSO 133.Xr humanize_number 9 134.Sh HISTORY | 129.Fa buffer 130(excluding the terminating NUL) upon success, or \-1 upon failure. 131If 132.Dv HN_GETSCALE 133is specified, the prefix index number will be returned instead. 134.Sh SEE ALSO 135.Xr humanize_number 9 136.Sh HISTORY |
137The |
|
135.Fn humanize_number | 138.Fn humanize_number |
136first appeared in | 139function first appeared in |
137.Nx 2.0 . | 140.Nx 2.0 . |