In general, there is a decimal fractional number 245,71 translate it into binary, I get 11110101,010 . I check my result: 0x2^-3 + 0x2^-2 + 0x2^-1 + 1x2^0 + 0x2^1 + 1x2^2 + 0x2^3 + 1x2^4 + 1x2^5 + 1x2^6 + 1x2^7 (I think I wrote it this way.) The whole number I get is correct: 245 , but if with a fractional, it turns out 246,625 .

Maybe I do not think so: " 0x2^-3 + 0x2^-2 + 0x2^-1 "? With math I have tight. ((

PS * has replaced the multiplication sign with x, because it takes an asterisk as a bb-tag.

  • Here damn how not cool 71 degree does not get! Will the number be anyway even, or am I a fool? - Nu3oN

2 answers 2

What does it mean not to get 0.71? IAZ gave you a link where it is clearly defined what and where. Conversion to binary fractions differs from similar conversion of integers.

In your example, 245.71:

  1. We translate 245 - we can do it.

  2. Now according to the algorithm (in parentheses - the binary number):

    0.71x2 = 1.42 (1) [0.5]

    0.42x2 = 0.84 (0) [0.25]

    0.84x2 = 1.68 (1) [0.125]

    0.68x2 = 1.36 (1) [0.0625]

    0.36x2 = 0.72 (0) [0.03125]

    0.72x2 = 1.44 (1) [0.015625]

    0.44x2 = 0.88 (0) [0.0078125]

    0.88x2 = 1.76 (1) [0.00390625]

    0.76x2 = 1.52 (1) [0.001953125]

    0.52x2 = 1.04 (1) [0.0009765625]

We 1x0.5 + 0x0.25 + 1x0.125 + 1x0.0625 + 0x0.03125 + 1x0.015625 + 0x0.0078125 + 1x0.00390625 + 1x0.001953125 + 1x0.0009765625 = 0,7099609375 : 1x0.5 + 0x0.25 + 1x0.125 + 1x0.0625 + 0x0.03125 + 1x0.015625 + 0x0.0078125 + 1x0.00390625 + 1x0.001953125 + 1x0.0009765625 = 0,7099609375 (further calculations depend on required accuracy). Here is your number in binary 11110101.1011010111 .

Tell me, what is really in this expression "0x2^-3 + 0x2^-2 + 0x2^-1" turns out 0.625? As for me so there, this type of zero. You are probably the unit in the second digit lost. But even in this case, 0.625 somehow does not work. In general, something you namudri or I do not understand something.

    See how to convert fractional numbers to binary .

    For example, your number: 245.71 = 11110101.101101

    • This is a little something ... more precisely, but not for this occasion! - Nu3oN
    • @ Nu3oN for what "not this case"? What are you talking about? - IAZ