summaryrefslogtreecommitdiff
path: root/modules/gdscript/tests/scripts/parser/features/float_notation.gd
blob: b207b8882093dfbcaa0f6f1389afd9c666d04601 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
func test():
	# The following floating-point notations are all valid:
	print(is_equal_approx(123., 123))
	print(is_equal_approx(.123, 0.123))
	print(is_equal_approx(.123e4, 1230))
	print(is_equal_approx(123.e4, 1.23e6))
	print(is_equal_approx(.123e-1, 0.0123))
	print(is_equal_approx(123.e-1, 12.3))

	# Same as above, but with negative numbers.
	print(is_equal_approx(-123., -123))
	print(is_equal_approx(-.123, -0.123))
	print(is_equal_approx(-.123e4, -1230))
	print(is_equal_approx(-123.e4, -1.23e6))
	print(is_equal_approx(-.123e-1, -0.0123))
	print(is_equal_approx(-123.e-1, -12.3))

	# Same as above, but with explicit positive numbers (which is redundant).
	print(is_equal_approx(+123., +123))
	print(is_equal_approx(+.123, +0.123))
	print(is_equal_approx(+.123e4, +1230))
	print(is_equal_approx(+123.e4, +1.23e6))
	print(is_equal_approx(+.123e-1, +0.0123))
	print(is_equal_approx(+123.e-1, +12.3))