Connexion
Applications Google
Menu principal
Post a Comment On:
Only Python
"Approximate fun"
No comments yet. -
1 – 0 of 0
Newest addition to https://github.com/aroberge/experimental
> python -m experimental
experimental console version 0.9.6. [Python version: 3.6.1]
~~> from __experimental__ import approx
~~> 0.1 + 0.2
0.30000000000000004
~~> 0.1 + 0.2 == 0.3
False
~~> # Attempt to use approximate comparison with defining tolerances
~~> 0.1 + 0.2 ~= 0.3
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'rel_tol' is not defined
~~> rel_tol = abs_tol = 1e-8
~~> 0.1 + 0.2 ~= 0.3
True
~~> 2**0.5 ~= 1.414
False
~~> abs_tol = 0.001
~~> 2**0.5 ~= 1.414
True
posted by André Roberge at
8:36 AM
on Jun 18, 2018
Leave your comment
Spammers: none shall pass.
You can use some HTML tags, such as
<b>, <i>, <a>
Comments on this blog are restricted to team members.
Google Account
You will be asked to sign in after submitting your comment.
Please prove you're not a robot
"Approximate fun"
No comments yet. -