how to convert numbers in decimal to binary?

Ben is right. This is not as easy a problem as converting an integer to

binary (which I recently posted some untested code to do) where you do

repeated divisions and modulo remainders to put numbers into a reversed

string ...

However, and I won't make an off the cuff effort to do this, but you can do

something similar (with some complexity that doesn't happen in the integer

case) for decimal fractions -- fairly obvious since the internal

representation is binary.

Take the fractional part only

Multiply by two: if the result is greater than 1, the first fractional bit

is 1, otherwise it is zero

Take the fractional part of the resulting number

Multiply by two: if the result is greater than 1, the next fractional bit is

1, otherwise it is zero

Seems like a pattern is emerging here

So, what's the problem ... think about the exact representation of some

decimal fraction like 0.1 in binary ... doesn't seem to exist, so you have

to make some intelligent choices about where you will cut everything off.

Perhaps a legitimate question to ask here (as well as in a separate thread)

is what support the C99 standard may have for binary literals. Introductory

material in the standard says that one of the changes is to support "binary

floating-point literals" and the printf and scanf modifiers. I am not quite

sure how to interpret this.

Regards,

Sam