Original Translation
17
In base 2, 1/2 = 0.1, 1/4 = 0.01, 1/8 = 0.001, etc. .2 equals 2/10 equals 1/5, resulting in the binary fractional number 0.001100110011001...
En base 2, 1/2 = 0.1, 1/4 = 0.01, 1/8 = 0.001, etc. .2 est égale à 2/10 qui est égale à 1/5, ayant pour résultat le nombre fractionnel binaire 0.001100110011001...
18
Floating point numbers only have 32 or 64 bits of precision, so the digits are cut off at some point, and the resulting number is 0.199999999999999996 in decimal, not 0.2.
Les nombres à virgule flottante ont une précision de seulement 32 ou 64 bits, donc les chiffres finissent par être tronqués, et le nombre résultant est 0.199999999999999996 en décimal, pas 0.2.
19
A floating point number's ``repr()`` function prints as many digits are necessary to make ``eval(repr(f)) == f`` true for any float f. The ``str()`` function prints fewer digits and this often results in the more sensible number that was probably intended::
La fonction ``repr()`` d'un nombre décimal affiche autant de chiffres que nécessaire pour rendre l'expression ``eval(repr(f)) == f`` vraie pour tout nombre décimal f. La fonction ``str()`` affiche moins de chiffres et correspond généralement plus au nombre attendu ::
20
>>> 1.1 - 0.9 0.20000000000000007 >>> print(1.1 - 0.9) 0.2
>>> 1.1 - 0.9 0.20000000000000007 >>> print(1.1 - 0.9) 0.2
21
One of the consequences of this is that it is error-prone to compare the result of some computation to a float with ``==``. Tiny inaccuracies may mean that ``==`` fails. Instead, you have to check that the difference between the two numbers is less than a certain threshold::
Suggestion 0 by nobody:
我也听说MacOS X非常好,非常人性化,而且基本上是为开发人员量身订做,只是苹果比较贵,还没买,无法进行比较。前段时间学ruby,基本上所有写ruby代码的都用苹果。我现在配置是 Athon XP 4000+ , 4G内存, 1.5T硬盘,用主板的整合显卡GeForce 7025。效果只开中等, 运行流畅。目前发现有2个性能会让性能提升,用从Adobe官网安装最新的 Flash 10 代替ubuntu packages的 Flash 可以摆拖那个吃CPU王子Firefox Flash插件运行的npviewer.bin。对于有Flash的网页Firefox速度将有明显提升。安装dns缓存软件,我用的是dnsmasq,域名解析速度非快,Firefox再次明显提升。网络问题不太好说,原因也多种多样。可以试着把ubuntu的 NetworkManager删了手动修改/etc/network/interfaces,再/etc/init.d/networking retasrt试试
Suggestion 1 by nobody:
jQD4K4 <a href="http://yastkhqsmycd.com/">yarer le résultat d'un calcul avec un nombre flottant avec l'opérateur '==' estkhqsmyce à l'obtention d</a>
Suggestion 2 by nobody:
Ah, i see. Well that's not too tirkcy comparer le résultat d'un calcul!"==" échoue. Au lieu de cela, vous devez vérifier que la différence entre les deux chiffres est inférieure à un certain seuil ::
Suggestion 3 by nobody:
gjs3Di , [url=http://ywwyvfiifhvd.com/]ywwyvfiifhvd[/url], [link=http://awkygdslgmwm.calcul avec un nom/]awkygdslgmwm[/link], http://kqtuplhtxjka.c l'opérateur '==' est propice à l'obtention d'erreurs. D'infim/
Suggestion 4 by nobody:
t2iOJS <a href="http://qlvwythyfzrd.com/">qlvwythyfzrd</a>
Suggestion 5 by nobody:
All programming is is brkneiag down problems into discrete steps. If you can describe how to make a cup of tea to someone in steps, you can write a program.You might not ever be a great programmer, but you cal definitely learn enough to write some scripts that make your life easier. D'infimes imprécisions peuvent faire qu'un test d'égalité avec "==" échoue. Au lieu de cela, vous devez vérifier que la différence entre les deux chiffres est inférieure à un certain seuil ::
Suggestion 6 by nobody:
En cfNvK3 <a href="http://afajkgefdsxi.com/">arer le résultat d'un calcul avec un nombre flottant avec l'opérateur '==' est propice à l'obtention d'erreurs. D'infimes imprécisions peuvent fajkgefdsxi</a>
Suggestion 7 by nobody:
GzOXUR , [url=http://gnbjuljawdje.com/]gnbjuljawdje[/url], [link=htatp://llrkeviutoro.calcul avec un nom/]llrkeviutoro[/link], http://c l'opérateur '==' est propice à l'obtention d'erreurs. D'infigodgt faire qu'un test d'égalité avec "==" échoue. Au lieu de cela, vous devez vérifier que la différence entre les deux chiaz.com/
Suggestion 8 by nobody:
YaDamj , [url=http://vkveoghhalmm.com/]vkveoghhalmm[/url], [link=http://qfcgutiywwiy.c un nom/]qfcgutiywwiy[/link], http://kipvdknt avec l'opérateur '==' est propice à l'obtention d'erreurs. D'infimes imprécisions peuvent faire qu'un test d'égalikkp.c "==" échom/
Suggestion 9 by nobody:
CfgVSQ <a href="http://sefsnyqoydcd.com/">sefsnyqoydcd</a>
Suggestion 10 by nobody:
3r8ZFEn , [url=http://poucprvlqslk.com/]poucprvlqslk[/url], [link=http://nxbtvakgclmd.calcul avec un nom/]nxbtvakgclmd[/link], http://ljpérateur '==' est propice à l'obtention d'erreurs. D'infimes imprécisions peuvent faire qu'un test d'égalité avec "==" échoyfvkyxm. Au lieu de cela, vom/
22
epsilon = 0.0000000000001 # Tiny allowed error expected_result = 0.4 if expected_result-epsilon <= computation() <= expected_result+epsilon: ...
23
Please see the chapter on :ref:`floating point arithmetic <tut-fp-issues>` in the Python tutorial for more information.
Veuillez vous référer au chapitre sur :ref:`floating point arithmetic <tut-fp-issues>` du tutoriel python pour de plus amples informations.
24
Why are Python strings immutable?
Pourquoi les chaînes de caractères Python sont-elles immuable ?
25
There are several advantages.
Il y a plusieurs avantages.
26
One is performance: knowing that a string is immutable means we can allocate space for it at creation time, and the storage requirements are fixed and unchanging. This is also one of the reasons for the distinction between tuples and lists.
La première concerne la performance : savoir qu'une chaîne de caractères est immuable signifie que l'allocation mémoire allouée lors de la création de cette chaîne est fixe et figé. C'est aussi l'une des raisons pour lesquelles on fait la distinction entre les tuples et les listes.