How can we convert negative double value to binary value in matlab?
이전 댓글 표시
I'm the student of UCSY.I research for audio scrambling. In my research, I need to scarmble audio data with key using bit wise xor.Now,I have difficulties to convert negative float value to binary value to scramble. Please, anyone can help me?? I would be grateful if someone help me in this matter.
댓글 수: 6
KALYAN ACHARJYA
2018년 2월 3일
No inbuilt function. "float2bin" user defined function you may search.
Su Latt Sandi
2018년 2월 3일
Rik
2018년 2월 3일
How would you want to convert values to binary? For positive integers this is obvious (and you can use the built in dec2bin), but for all other values it isn't. double and single are already floats, and have a binary representation, but I don't see how that would benefit you for XOR. If you describe what shape the output should have, we can help you.
Su Latt Sandi
2018년 2월 3일
Su Latt Sandi
2018년 2월 4일
Walter Roberson
2018년 2월 4일
num2bin() is for Fixed Point Objects, not for general numbers.
num2bin returns characters, so subtract '0' (the character for the digit 0) to get the numeric values.
채택된 답변
추가 답변 (1개)
Use BITGET, for example,
>> bitget(-25,1:8,'int8')
ans =
1 1 1 0 0 1 1 1
댓글 수: 1
Walter Roberson
2018년 2월 3일
That only works for values that are integers.
You can experiment with
bitget(typecast(-25.2, 'uint64'), 1:8)
but beware that the byte order might not be what you are expecting.
카테고리
도움말 센터 및 File Exchange에서 Direction of Arrival Estimation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!