OVH Cloud OVH Cloud

Probleme d'arrondi

3 réponses
Avatar
J. Smith
Bonjour :

Comment expliquez-vous que l'exécution de ce script donne comme résultat :

1.2000000000000001
1.2000000000000001

------------------------------------------------------------------
<html><body>

<div id="toto"></div>
<div id="toto2"></div>

<script language="javascript">
document.getElementById('toto').innerHTML = 12 * 0.1;
document.getElementById('toto2').innerHTML = 12.0 * 0.1;
</script>

</body></html>
------------------------------------------------------------------

Merci.

3 réponses

Avatar
J. Smith
Merci

"denisb" a écrit dans le message de
news:1gu7lrz.1jqqvzql0eu0N%
J. Smith wrote:
passque : <http://jibbering.com/faq/#FAQ4_7>
(lire aussi le 4.6)


Avatar
newdb
J. Smith wrote:
Comment expliquez-vous que l'exécution de ce script donne comme résultat :
1.2000000000000001
1.2000000000000001
<html><body>
<div id="toto"></div>
<div id="toto2"></div>
<script language="javascript">
document.getElementById('toto').innerHTML = 12 * 0.1;
document.getElementById('toto2').innerHTML = 12.0 * 0.1;
</script>
</body></html>


passque : <http://jibbering.com/faq/#FAQ4_7>
(lire aussi le 4.6)

--
@@@@@
E -00 comme on est very beaux dis !
' `) /
|_ =="

Avatar
Dr John Stockton
JRS: In article <4249c7fc$0$15070$, dated Tue, 29
Mar 2005 23:27:40, seen in news:fr.comp.lang.javascript, J. Smith
posted :

Comment expliquez-vous que l'exécution de ce script donne comme résultat :

1.2000000000000001
1.2000000000000001


<URL:http://www.merlyn.demon.co.uk/js-maths.htm#Float>.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.