2013-12-29 22:34:42 +00:00
|
|
|
# basic float
|
|
|
|
x = 1 / 2
|
|
|
|
print(x)
|
2014-03-31 00:20:00 +01:00
|
|
|
|
2015-03-12 22:47:44 +00:00
|
|
|
# /= operator
|
|
|
|
a = 1
|
|
|
|
a /= 2
|
|
|
|
print(a)
|
|
|
|
|
2014-03-31 00:20:00 +01:00
|
|
|
print(1.0 // 2)
|
|
|
|
print(2.0 // 2)
|
|
|
|
|
|
|
|
try:
|
|
|
|
1.0 / 0
|
|
|
|
except ZeroDivisionError:
|
|
|
|
print("ZeroDivisionError")
|
|
|
|
|
|
|
|
try:
|
|
|
|
1.0 // 0
|
|
|
|
except ZeroDivisionError:
|
|
|
|
print("ZeroDivisionError")
|
2015-02-08 01:57:40 +00:00
|
|
|
|
|
|
|
# test constant float with more than 255 chars
|
|
|
|
x = 1.84728699436059052516398251149631771898472869943605905251639825114963177189847286994360590525163982511496317718984728699436059052516398251149631771898472869943605905251639825114963177189847286994360590525163982511496317718984728699436059052516398251149631771898472869943605905251639825114963177189
|
|
|
|
print("%.5f" % x)
|