expand_number (3)
Leading comments
Copyright (c) 2007 Eric Anderson <anderson@FreeBSD.org> Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this lis...
NAME
expand_number - format a number from human readable formLIBRARY
Lb libbsdSYNOPSIS
In libutil.h (See libbsd(7) for include usage.) Ft int Fo expand_number Fa const char *buf uint64_t *num FcDESCRIPTION
The Fn expand_number function unformats the Fa buf string and stores a unsigned 64-bit quantity at address pointed out by the Fa num argument.The Fn expand_number function follows the SI power of two convention.
The prefixes are:
- Prefix Ta Description Ta Multiplier
- k Ta kilo Ta 1024
- M Ta mega Ta 1048576
- G Ta giga Ta 1073741824
- T Ta tera Ta 1099511627776
- P Ta peta Ta 1125899906842624
- E Ta exa Ta 1152921504606846976
RETURN VALUES
Rv -stdERRORS
The Fn expand_number function will fail if:- Bq Er EINVAL
- The given string contains no digits.
- Bq Er EINVAL
- An unrecognized prefix was given.
- Bq Er ERANGE
- Result doesn't fit into 64 bits.