I want to convert a floating point number (or a decimal number say
123.456) into binary notation using a C program. Can somebody help me
out with it?
What, _exactly_, have you got; what, exactly do you want? Have you got a
float in memory, or a string containing "123.456"? Do you want a float
in memory (since all C objects are stored binarily), or do you want a
string containing "1010.1010"?
If you want to go from string to object, use strtod().
If you want to go from object to binary representation in memory, do
nothing; you've already got it.
If you want to go from object to string, that's harder; there is no
built-in printf() specifier for binary as there is for decimal and hex,
so you'll have to roll your own. Keep dividing by two and adding ones or
zeroes depending on the modulus.
If you want to go from decimal representation string to binary
representation string, it's probably easiest to use strtod() first and
then apply the previous solution.
Richard