How do i covert negative decimal numbers into binary??. For example,
a=[-5.5 -2 1.0 3.2 -6.3]; to equivalent binary.
I tried to convert them to 2's complement as follows:
a=-5;
b=dec2bin(2^4+a);
this works fine for the numbers without decimal point.
Can anyone tell me how to do the conversion with decimal point.
Thanks !
Ashwini
2's complement is a scheme used for storing integers. What, exactly, would you expect such a scheme to do with fractional inputs?
James Tursa
Thanks !
I want binary equivalent of any negative decimal integer. For Ex: -5.5.
How do i do this ??
Thanks,
Ashwini
> Thanks !
> I want binary equivalent of any negative decimal integer. For Ex: -5.5.
But how would you define 2's complement for non-integer quantities?
In your example, what would the binary representation of -5.5 be?
that is what i am looking for ..
for only negative quantities i followed the step mentioned below:
a=-5;
b=dec2bin(2^4+a);
how about negative decimail.
Requirement is that, i have FSK modulate sound file (.wav) which will have both positive and negative decimals .. how do i convert them into equivalent binary data?? whithout converting them into zeros and ones i can not modulate.
Any idea ???
Thanks !
Ashwini
> > But how would you define 2's complement for non-integer quantities?
> > In your example, what would the binary representation of -5.5 be?
>
> that is what i am looking for ..
> for only negative quantities i followed the step mentioned below:
> a=-5;
> b=dec2bin(2^4+a);
>
> how about negative decimail.
> Requirement is that, i have FSK modulate sound file (.wav) which will have both positive and negative decimals .. how do i convert them into equivalent binary data?? whithout converting them into zeros and ones i can not modulate.
================================
Could you pre-scale all of your decimals to make them integer. For example, all of your example data had a single decimal point, so you could pre-convert them to intergers by multiplying them all by 10. Then you could convert them to binary as above and, if need be, unscale them later at the end of your processing chain.
Thanks Matt,
Is is very good idea .. let me try it out and check how faithfully i can get back my voice signal after demodulation.
Ashwini
Hey Matt,
It works well, thanks a lot ...
(The demodulated wave is almost resembling the original wave)
Ashwini