回答編集履歴
2
fix context
answer
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
[丸め誤差](https://www.google.com/search?q=%E4%B8%B8%E3%82%81%E8%AA%A4%E5%B7%AE)を参照してください.
|
2
2
|
|
3
|
+
以下対処例
|
3
4
|
```python
|
4
5
|
from fractions import Fraction
|
5
6
|
|
1
fix ans
answer
CHANGED
@@ -1,1 +1,14 @@
|
|
1
|
-
[丸め誤差](https://www.google.com/search?q=%E4%B8%B8%E3%82%81%E8%AA%A4%E5%B7%AE)を参照してください.
|
1
|
+
[丸め誤差](https://www.google.com/search?q=%E4%B8%B8%E3%82%81%E8%AA%A4%E5%B7%AE)を参照してください.
|
2
|
+
|
3
|
+
```python
|
4
|
+
from fractions import Fraction
|
5
|
+
|
6
|
+
x = 151.67168989437898493880
|
7
|
+
|
8
|
+
_x = Fraction(str(x)[:7])
|
9
|
+
_sell1 = _x - Fraction(2, 100)
|
10
|
+
_sell2 = _x + Fraction(3, 100)
|
11
|
+
|
12
|
+
print(_x, _sell1, _sell2, sep=', ') # 151671/1000, 151651/1000, 151701/1000
|
13
|
+
print(float(_x), float(_sell1), float(_sell2), sep=', ') # 151.671, 151.651, 151.701
|
14
|
+
```
|