1print("%s" % 1.0)
2print("%r" % 1.0)
3
4print("%d" % 1.0)
5print("%i" % 1.0)
6print("%u" % 1.0)
7
8# these 3 have different behaviour in Python 3.x versions
9# uPy raises a TypeError, following Python 3.5 (earlier versions don't)
10# print("%x" % 18.0)
11# print("%o" % 18.0)
12# print("%X" % 18.0)
13
14print("%e" % 1.23456)
15print("%E" % 1.23456)
16print("%f" % 1.23456)
17print("%F" % 1.23456)
18print("%g" % 1.23456)
19print("%G" % 1.23456)
20
21print("%06e" % float("inf"))
22print("%06e" % float("-inf"))
23print("%06e" % float("nan"))
24
25print("%02.3d" % 123)  # prec > width
26print("%+f %+f" % (1.23, -1.23))  # float sign
27print("% f % f" % (1.23, -1.23))  # float space sign
28print("%0f" % -1.23)  # negative number with 0 padding
29
30# numbers with large negative exponents
31print("%f" % 1e-10)
32print("%f" % 1e-20)
33print("%f" % 1e-50)
34print("%f" % 1e-100)
35print("%f" % 1e-300)
36
37# large decimal precision should be truncated and not overflow buffer
38# the output depends on the FP calculation so only first 2 digits are printed
39# (the 'g' with small e are printed using 'f' style, so need to be checked)
40print(("%.40f" % 1e-300)[:2])
41print(("%.40g" % 1e-1)[:2])
42print(("%.40g" % 1e-2)[:2])
43print(("%.40g" % 1e-3)[:2])
44print(("%.40g" % 1e-4)[:2])
45
46print("%.0g" % 1)  # 0 precision 'g'
47
48print("%.1e" % 9.99)  # round up with positive exponent
49print("%.1e" % 0.999)  # round up with negative exponent
50