Объяснение бага в Excel
отметили
2
человека
в архиве
Look closely at the binary representation for 77.1:
0100 0000 0101 0011 0100 0110 0110 0110
0110 0110 0110 0110 0110 0110 0110 0110
See how there's a lot of 0110 0110 0110 there at the end? That's because 0.1 has no exact representation in binary… it's a repeating binary number. It's sort of like how 1/3 has no representation in decimal. 1/3 is 0.33333333 and you have to keep writing 3's forever. If you lose patience, you get something inexact.
So you can imagine how, in decimal, if you tried to do 3*1/3, and you didn't have time to write 3's forever, the result you would get would be 0.99999999, not 1, and people would get angry with you for being wrong.
0100 0000 0101 0011 0100 0110 0110 0110
0110 0110 0110 0110 0110 0110 0110 0110
See how there's a lot of 0110 0110 0110 there at the end? That's because 0.1 has no exact representation in binary… it's a repeating binary number. It's sort of like how 1/3 has no representation in decimal. 1/3 is 0.33333333 and you have to keep writing 3's forever. If you lose patience, you get something inexact.
So you can imagine how, in decimal, if you tried to do 3*1/3, and you didn't have time to write 3's forever, the result you would get would be 0.99999999, not 1, and people would get angry with you for being wrong.
Источник:
joelonsoftware.com/items/2007/...
Добавил
webcasper 28 Сентября 2007

нет комментариев
проблема (2)
Комментарии участников:
Ни одного комментария пока не добавлено