summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/Config.in8
-rw-r--r--miscutils/dc.c4
2 files changed, 12 insertions, 0 deletions
diff --git a/miscutils/Config.in b/miscutils/Config.in
index 0c80ae6..15f677a 100644
--- a/miscutils/Config.in
+++ b/miscutils/Config.in
@@ -138,6 +138,14 @@ config DC
Dc is a reverse-polish desk calculator which supports unlimited
precision arithmetic.
+config FEATURE_DC_LIBM
+ bool "Enable power and exp functions (requires libm)"
+ default n
+ depends on DC
+ help
+ Enable power and exp functions.
+ NOTE: This will require libm to be present for linking.
+
config DEVFSD
bool "devfsd (obsolete)"
default n
diff --git a/miscutils/dc.c b/miscutils/dc.c
index 47ec060..7d5886e 100644
--- a/miscutils/dc.c
+++ b/miscutils/dc.c
@@ -53,12 +53,14 @@ static void mul(void)
push(pop() * pop());
}
+#if ENABLE_FEATURE_DC_LIBM
static void power(void)
{
double topower = pop();
push(pow(pop(), topower));
}
+#endif
static void divide(void)
{
@@ -137,9 +139,11 @@ static const struct op operators[] = {
{"mul", mul},
{"/", divide},
{"div", divide},
+#if ENABLE_FEATURE_DC_LIBM
{"**", power},
{"exp", power},
{"pow", power},
+#endif
{"%", mod},
{"mod", mod},
{"and", and},