"Roger Stafford" wrote in message <jbbfnl$8v6$1@newscl01ah.mathworks.com>...
> "hend " <eng.hr2009@yahoo.com> wrote in message <jbab7h$47b$1@newscl01ah.mathworks.com>...
> > i'm in need to a program code which can convert negative fractions into binary form ( any form ) ..
> > dec2bin command is not helpful in this case !
>         
> You can use 'dec2bin' if you help it out a bit. As an example, suppose you want to display 16 fractional binary digits on the number 1/(4*pi).
>
> d = 16;
> x = 1/(4*pi);
>
> b = sign(x);
> t = round(2^d*abs(x));
> [~,e] = log2(t);
> s = dec2bin(t,max(d,e));
> s = [s(1:endd),'.',s(endd+1:end)];
> if b<0, s = ['',s]; end
>
> The string s is the result. This code may not be quite the format you want but if not perhaps you can modify it appropriately.
>
> Roger Stafford
Hi Roger,
How will you convert the negative fractional binary number back to the decimal number?
With regards,
Shyamsunder
