diff options
| author | Mistivia <i@mistivia.com> | 2025-07-01 01:30:40 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-07-01 01:30:40 +0800 |
| commit | cdff133ab8e8a0c9ec62586abc3729a14e1cbba5 (patch) | |
| tree | d1ccf2fab2099047cacc41d7182bdb8c40c4e790 | |
| parent | e11f5d02afc9130c1398eeb3e2d25cd965bef27e (diff) | |
fix div bug
| -rw-r--r-- | Makefile | 5 | ||||
| -rw-r--r-- | src/builtins.c | 2 | ||||
| -rw-r--r-- | tests/math.lisp | 2 |
3 files changed, 5 insertions, 4 deletions
@@ -2,7 +2,6 @@ mode ?= debug cc = gcc includes = -DWITHREADLINE -I3rdparty/algds/build/include/ -#includes = -I3rdparty/algds/build/include/ 3rdlibs = 3rdparty/algds/build/lib/libalgds.a ldflags = -lm -lreadline @@ -10,8 +9,8 @@ ifeq ($(mode), debug) cflags = $(includes) \ -g \ -fsanitize=address -else ifeq ($(mode), debug) - cflags = $(includes) -g -flto -O2 +else + cflags = $(includes) -flto -O2 endif src = $(shell find src/ -name '*.c' -not -name 'main.c') diff --git a/src/builtins.c b/src/builtins.c index 9f605c1..f1c7d10 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -1220,7 +1220,7 @@ SExpRef builtin_div(Interp *interp, SExpRef args) { if (args_len == 1) { SExp num = *REF(CAR(args)); if (num.type == kIntegerSExp) { - return new_integer(interp, 1.0/num.integer); + return new_real(interp, 1.0/num.integer); } return new_real(interp, 1.0/num.real); } diff --git a/tests/math.lisp b/tests/math.lisp index cbd5298..4ecf876 100644 --- a/tests/math.lisp +++ b/tests/math.lisp @@ -9,6 +9,8 @@ (assert (= 1 (abs 1))) (assert (= 1.1 (abs 1.1))) +(~~ 0.2 (/ 5)) + (~~ 3.141 pi) (assert-error (~~ 3.2 pi)) |
