Reputation: 11
I have a binary number and I want to save it on a txt file.my code is :
fid=fopen('RT.txt','w')
fprintf(fid,'%d',00111111100000000000000000000000 );
fclose(fid);
But the saved value in file is : 1.111111e+029 I exactly want to save the value as the same as it is in binary format(32bit like the number that I wrote here) can you help me plssss
Upvotes: 0
Views: 1400
Reputation: 1739
00111111100000000000000000000000
is not a binary number in MATLAB. You can save it as a string '00111111100000000000000000000000'
, or if you want to convert the binary string to a decimal number, you can use bin2dec('00111111100000000000000000000000')
. And to convert a decimal number to a binary string (which is still an array of characters), use dec2bin(33)
.
Upvotes: 4