Since my 1st computer science class in 1966, there has always been a red flag in dealing with floating point numbers.
Never test for exact equality of two floating point numbers, especially if one of them is computed
Your original loop only ended when the computed value of "a" was precisely equal to "0.0". That's a red flag. Floating operations always leave some cumulative fractional part laying around.
There may be other things wrong with this code, I didn't try to debug it, only comment on the "loop ending condition"
--------------------------
OK, I ran your program and got this strange output. I have no idea what this program is supposed to do and have no idea what's wrong with it or what output you expect. It makes no sense to me at all.
123.456
0.456 0.912
.0
0.824
1.648
.01
0.648
1.296
.011
0.296
0.592
.01110
0.184
0.368
.0111010
.01110100
0.472
0.944
.0111010010
0.888
1.776
.01110100101
0.776
1.552
.011101001011
0.552
1.104
.0111010010111
0.104
0.208
.011101001011110
.0111010010111100
.01110100101111000
0.664
1.328
.011101001011110001
0.328
0.656
.01110100101111000110
0.312
0.624
.0111010010111100011010
0.248
0.496
.011101001011110001101010
.0111010010111100011010100
0.984
1.968
.01110100101111000110101001