Есть код
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MD5 hash loop</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="md5.js"></script>
</head>
<body>
<div class="container">
<input type="text" class="startFrom">Start from
<button class="start">Start</button>
<div class="out">
<p></p>
</div>
</div>
<script>
$('.start').click(function(){
startfrom = $('.startFrom').val();
console.log(parseFloat(startfrom));
i = parseFloat(startfrom);
do {
result = $('.out').html();
$('.out').html(result + i + " = " + hex_md5(String(i)) + "<br/>");
i = i + 0.000000000000000001;
}while(i<1);
result = result + $('.out p').html(hex_md5(startfrom) + "<br/>");
});
</script>
</body>
Код md5.js
здесь
В результате выводит:
0.1 = cb5ae17636e975f9bf71ddf5bc542075
0.2 = 3d522deaf85577451c01974654b36ad3
0.30000000000000004 = f8b37f00bdc6a8c31de8bbe2cc2b053a
0.4 = 54fbf38cf649866815e0fefc46a1f6c7
0.5 = d310cb367d993fb6fb584b198a2fd72c
0.6 = e95e1ca27d0e39aa03eb5a611ce4122f
0.7 = 91c85f899e56014969935fefd68830b9
0.7999999999999999 = 9f8151ace25ffe2a177de2290defd52e
0.8999999999999999 = e6946e23e2d9277cd86ff0f39c0ca972
0.9999999999999999 = ad9148c738aeafe6e223de49b744e31f
Почему получаются значения 0.8999999999999999 , 0.7999999999999999 , 0.30000000000000004?