blob: c3a0df0276bf8472ed25ae6ebd7bee45cc206727 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# test constant optimisation, with consts that are floats
from micropython import const
# check we can make consts from floats
F1 = const(2.5)
F2 = const(-0.3)
print(type(F1), F1)
print(type(F2), F2)
# check arithmetic with floats
F3 = const(F1 + F2)
F4 = const(F1**2)
print(F3, F4)
# check int operations with float results
F5 = const(1 / 2)
F6 = const(2**-2)
print(F5, F6)
# note: we also test float expression folding when
# we're compiling test cases in tests/float, as
# many expressions are resolved at compile time.
|