mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Update mathematical functions (#675)
Document the existing `ROUND`, `CEIL`, and `FLOOR` functions Also update the trig function docs for searchability Implement `POW` and `LOG` Addresses part of #675 Implement ** for integer exponents ** has higher precedence than -, like Python, so -3**4 == -(3**4) == 81
This commit is contained in:
40
test/asm/math.asm
Normal file
40
test/asm/math.asm
Normal file
@@ -0,0 +1,40 @@
|
||||
X equ 0
|
||||
|
||||
test: MACRO
|
||||
; Test RGBASM
|
||||
v equs "X +"
|
||||
static_assert \#
|
||||
purge v
|
||||
; Test RGBLINK
|
||||
v equs "Y +"
|
||||
assert \#
|
||||
purge v
|
||||
ENDM
|
||||
|
||||
test (v 2)*(v 10)**(v 2)*(v 2) == (v 400)
|
||||
test -(v 3)**(v 4) == v -81
|
||||
|
||||
assert DIV(5.0, 2.0) == 2.5
|
||||
assert DIV(-5.0, 2.0) == -2.5
|
||||
assert DIV(-5.0, 0.0) == $8000_0000
|
||||
|
||||
assert MUL(10.0, 0.5) == 5.0
|
||||
assert MUL(10.0, 0.0) == 0.0
|
||||
|
||||
assert POW(10.0, 2.0) == 100.0
|
||||
assert POW(100.0, 0.5) == 10.0
|
||||
|
||||
assert LOG(100.0, 10.0) == 2.0
|
||||
assert LOG(256.0, 2.0) == 8.0
|
||||
|
||||
assert ROUND(1.5) == 2.0
|
||||
assert ROUND(-1.5) == -2.0
|
||||
|
||||
assert CEIL(1.5) == 2.0
|
||||
assert CEIL(-1.5) == -1.0
|
||||
|
||||
assert FLOOR(1.5) == 1.0
|
||||
assert FLOOR(-1.5) == -2.0
|
||||
|
||||
SECTION "Y", ROM0
|
||||
Y::
|
||||
0
test/asm/math.err
Normal file
0
test/asm/math.err
Normal file
0
test/asm/math.out
Normal file
0
test/asm/math.out
Normal file
Reference in New Issue
Block a user