forked from len0rd/rockbox
lib/argparse scale decimals to int for return to user
scales the fractional portion of the parsed number by ARGPARSE_FRAC_DEC_MULTIPLIER Example ARGPARSE_FRAC_DEC_MULTIPLIER = 10 000 meaning .0009 returns 9 , 9 / 10000 = .0009 .009 returns 90 .099 returns 990 .09 returns 900 .9 returns 9000 .9999 returns 9999 Change-Id: I38573dbc1877760b0d52df8686a6647894d76196
This commit is contained in:
parent
d929444a41
commit
c04a944c98
2 changed files with 37 additions and 8 deletions
|
@ -23,6 +23,12 @@
|
|||
|
||||
#include "plugin.h"
|
||||
|
||||
#define ARGP_MAX_FRAC_DIGITS 9 /* Uses 30 bits max (0.999999999) */
|
||||
|
||||
#define ARGP_EXP(a, b) (a ##E## b)
|
||||
#define ARGP_FRAC_DEC_MULTIPLIER(n) AP_EXP(1,n) /*1x10^n*/
|
||||
#define ARGPARSE_FRAC_DEC_MULTIPLIER (long) ARGP_FRAC_DEC_MULTIPLIER(ARGP_MAX_FRAC_DIGITS)
|
||||
|
||||
/* fills buf with a string upto buf_sz, null terminates the buffer
|
||||
* strings break on WS by default but can be enclosed in single or double quotes
|
||||
* opening and closing quotes will not be included in the buffer but will be counted
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue