-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFloorCeilMathOperators.py
More file actions
99 lines (96 loc) · 2.27 KB
/
FloorCeilMathOperators.py
File metadata and controls
99 lines (96 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from math import *
print('''
print(floor(4))
print(floor(9.0))
print(floor(9.5))
print(floor(9,5)) # error)
''')
print(floor(4))
print(floor(9.0))
print(floor(9.5))
# error) print(floor(9,5))
print('''
print(floor(4.7))
print(floor(9.3))
print(floor(9.6))
print(floor(-4.7))
print(floor(-9.3))
print(floor(-9.6))
''')
print(floor(4.7))
print(floor(9.3))
print(floor(9.6))
print(floor(-4.7))
print(floor(-9.3))
print(floor(-9.6))
print('''
Towards infinity and away from zero are different things.
Example for (-1.2 and 3.4): "flooring" is towards
negative infinity (-2 and 3), "truncating" is towards zero
(-1 and 3), "saturating" is away from zero (-2 and 4),
and "ceiling" is towards positive infinity (-1 and 4).
''')
print('''
print(ceil(4))
print(ceil(9.0))
print(ceil(4,5) # error)
print(ceil(9,0) # error)
''')
#print(ceil(4,5)) # error
# error print(ceil(9,0))
print(ceil(4))
print(ceil(9.0))
print('''
print(ceil(4.7))
print(ceil(9.3))
print(ceil(9.6))
print(ceil(9.5))
print(ceil(-4.7))
print(ceil(-9.3))
print(ceil(-9.6))
print(ceil(-9.5))
''')
print(ceil(4.7))
print(ceil(9.3))
print(ceil(9.6))
print(ceil(9.5))
print(ceil(-4.7))
print(ceil(-9.3))
print(ceil(-9.6))
print(ceil(-9.5))
print('''
print(round(4,7))
print(round(9,3))
''')
print(round(4,7))
print(round(9,3))
print('''
print(round(4.7))
print(round(9.3))
print(round(9.6))
print(round(9.5))
print(round(-4.7))
print(round(-9.3))
print(round(-9.6))
print(round(-9.5))
''')
print(round(4.7))
print(round(9.3))
print(round(9.6))
print(round(9.5))
print(round(-4.7))
print(round(-9.3))
print(round(-9.6))
print(round(-9.5))
print('''
Floor Division(//) - The division of operands where the result is the quotient
in which the digits after the decimal point are removed. But if one of the
operands is negative, the result is floored, i.e.,
rounded away from zero (towards negative infinity): examples: 9//2 = 4 and
9.0//2.0 = 4.0, -11//3 = -4, -11.0//3 = -4.0
Towards infinity and away from zero are different things.
Example for (-1.2 and 3.4): "flooring" is towards
negative infinity (-2 and 3), "truncating" is towards zero
(-1 and 3), "saturating" is away from zero (-2 and 4),
and "ceiling" is towards positive infinity (-1 and 4).
''')