From f3d36cd46adaf0a977ae17a8b929185accdc6bd3 Mon Sep 17 00:00:00 2001 From: Souleymane DIALLO Date: Wed, 5 Nov 2025 23:31:55 +0000 Subject: [PATCH] feat(calc): add unary exponential (e^x) button --- public/client.js | 22 ++++++++++++++++++++++ public/index.html | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/public/client.js b/public/client.js index 9df4075..ebb421b 100644 --- a/public/client.js +++ b/public/client.js @@ -112,6 +112,28 @@ function signPressed() { } } +function expoPressed() { + // unary exponential: compute e^(current value) + var current = getValue(); + var n = Number(current); + + if (isNaN(n)) { + setError(); + return; + } + + setLoading(true); + try { + var result = Math.exp(n); + setValue(result); + state = states.complete; + } catch (e) { + setError(); + } finally { + setLoading(false); + } +} + function operationPressed(op) { operand1 = getValue(); operation = op; diff --git a/public/index.html b/public/index.html index 8fcfca5..4bf448b 100644 --- a/public/index.html +++ b/public/index.html @@ -43,7 +43,7 @@ - +