1 Aug 2011 11:53
binary pattern matching fails with 32-bit float, if decimal representation of the number cannot be converted to binary exactly
Вадзім Зенька <v <at> vadzim.info>
2011-08-01 09:53:42 GMT
2011-08-01 09:53:42 GMT
WHAT: binary pattern matching fails with 32-bit float, if decimal representation of the number cannot be converted to binary exactly EXAMPLE: following code fails: % "1.1" does not have exact binary representation > case <<1.1:32/float>> of <<1.1:32/float>> -> ok end. ** exception error: no case clause matching <<63,140,204,205>> > case <<63,140,204,205>> of <<1.1:32/float>> -> ok end. ** exception error: no case clause matching <<63,140,204,205>> although > case <<1.1:32/float>> of <<63,140,204,205>> -> ok end. ok % "1.5" has exact binary representation > case <<1.5:32/float>> of <<1.5:32/float>> -> ok end. ok % 64-bit floats work well > case <<1.1:64/float>> of <<1.1:64/float>> -> ok end. ok -- З павагай, Вадзім Зенька v <at> vadzim.info(Continue reading)
RSS Feed