|
datas are written in binary format in memory...
however, if you like to print an integer in binary format, this link[^] should help.
here is the sample :
<font color=#0000FF>LONGLONG</font> iVal = 125932; <font color=#008000>
CString strVal = <font color=#808080>""</font>; <font color=#008000>
<font color=#0000FF>for</font> (<font color=#0000FF>int</font> i = 0; i < <font color=#0000FF>sizeof</font>(LONGLONG); i++) {
strVal.Insert(0, ((iVal & 0x00000001) ? <font color=#808080>"1"</font> : <font color=#808080>"0"</font>));
iVal >>= 1;
}
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Thank you.
Pls read my reply to Joel Holdsworth.
|
|
|
|
|
fardak wrote:
Pls read my reply to Joel Holdsworth
hey, already done...
you define mystring as a TCHAR[], which need a trailing '\0' to be displayed correctly...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Thanks again.
I rewrote this:
void CMyBitsDlg::ConvertLLtoBin()
{ LONGLONG value = 12345;
TCHAR mystring[sizeof(LONGLONG)];
for(int i = 0; i < sizeof(LONGLONG); i++)
mystring[i] = ((value >> (sizeof(LONGLONG) - i - 1)) & 1) ? _T('1') : _T('0');
mystring[i]='\0'; //added
AfxMessageBox(mystring);
}
And the answer is 00111001 which is 39 hexadecimal.
So something is wrong.
But the strange thing happening now is that I have an error memory reading message.
|
|
|
|
|
Almost correct. You need to change
TCHAR mystring[sizeof(LONGLONG)]; to
TCHAR mystring[sizeof(LONGLONG) + 1]; and instead of writing
mystring[i]='\0'; try
mystring[sizeof(LONGLONG)] = 0; I think that might help
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
Thanks again.
Ok the last version is
void CMyBitsDlg::ConvertLLtoBin()
{ //LONGLONG value = 12345;
LONGLONG value = 0xFF FF FF FF FF FF FF FF;
TCHAR mystring[sizeof(LONGLONG)+1];
for(int i = 0; i < sizeof(LONGLONG); i++)
mystring[i] = ((value >> (sizeof(LONGLONG) - i - 1)) & 1) ? _T('1') : _T('0');
mystring[sizeof(LONGLONG)]='\0';
AfxMessageBox(mystring);
}
And the answer is 11 11 11 11
Instead od a 64 times '1'.
Where the rest has gone ?
|
|
|
|
|
|
Thank you for yor time and effort.
I tried you edited code with a value of
0xFF FF FF FF FF FF FF FF (//16 F)
and it gives 64 1's which is the correct answer .
Thanks again.
|
|
|
|
|
|
hum, well, it seems that the code is printing only the LSB and is missing the 0b 00110000 00111001
did you try my code ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Not yet,but I will and tell you about it.
Right now my head is spinning..dangerously!!
|
|
|
|
|
Thanks for the code you supplied.
I tried the one given by Joel Holdsworth,and it works perfectly well.
Here's the final version.
void CMyBitsDlg::ConvertLLtoBin()
{
LONGLONG value = 0xFFFFFFFFFFFFFFFF;//16 F
TCHAR mystring[sizeof(LONGLONG)*8 + 1];
for(int i = 0; i < sizeof(LONGLONG)*8; i++)
mystring[i] = ((value >> (sizeof(LONGLONG)*8 - i - 1)) & 1) ? _T('1') : _T('0');
mystring[sizeof(LONGLONG)*8] = 0;
AfxMessageBox(mystring);
}
The result is a 64 1's.
|
|
|
|
|
I'm so sorry to mess you around fardak! I'm really not thinking properly today! The problem is that sizeof(LONGLONG) is in bytes not bits. Change every reference to sizeof(LONGLONG) to sizeof(LONGLONG)*8, and everything should work out!
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
i tried to implement but i couldn't .i hope anyone could help me before 20 of this month
|
|
|
|
|
Hi,
I have alot of MFC and C++ Console applications & static library's.
I build all applications on Windows OS & main applications (console) on Linux (gcc gmake).
Which program do you guys advise to use to automated building so I can do building easily on Win & Linux? ant? Scons?
I realise this is not a general C++ question, but since you guys alsoo waste a lot of time building apps maybe anyone could give me some tips ..
Greetings,
Jens
|
|
|
|
|
JensB wrote:
Which program do you guys advise to use to automated building so I can do building easily on Win & Linux? ant? Scons?
gmake[^] is available for Linux and Windows
|
|
|
|
|
I'm trying to finish a report on DSP (digital signal processing) technique increasing effect of sound. However, I can't find any documents teaching about this technique on almost the webpages. I hope your help...You can give me a link to a webpage, a ebook ,and anything else about the technique...thanks so much <vtalau@yahoo.com>
|
|
|
|
|
try out thiz sire....very useful.....good forum for dsp stuff!!!!!
http://www.musicdsp.com/[^]
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
Hello,
I have developed Console based application . Now I want some code which will minimize the application to system tray and the process is running in the background.
I saw many codes but all are available for MFC or dialog based application .
can any one give me guidence or send me the code for the same.
Thanks in advacnce,
Rajat
|
|
|
|
|
In fact you don't want your console to be visible is it ?
See the : FAQ[^]
|
|
|
|
|
ya,
Basically its a continuously running process so i want it to minimize to system tray .
can any one please tell me how to get handle for the console window in vc++.
Thanks
|
|
|
|
|
I don't think this would be possible with a standard console application. I think (but I'm not sure) this is totally incopatible with the windows API and so, the taskbar is purely windows specific. I might be wrong but that sounds logical to me...
If you really need to do this, you will need to change your application and move it to a Win32 (or MFC) application
|
|
|
|
|
Hi..
I need to maintain a log file which will contain the time i started a playback.. and the time it ended.. What i have done is:
-> Get the current time and write it to log..
-> The code that takes care of sound playback..
-> Get the current time and write it to log..
The problem is .. both these times are same.. (the playback goes on for more than 10 secs..)
Can anyone help me out..
regards
pallavi
|
|
|
|
|
If you don't post the code, we won't be able to help you... Or at least the code that write the times in the log file.
|
|
|
|
|
Ya.. here it is..
CTime theTime=CTime::GetCurrentTime();
CString startTime=theTime.Format( "%H:%M:%S, %B %d, %Y" );
WriteLogFile(startTime);
m_pMyDS->Play();
CTime getTime=CTime::GetCurrentTime();
CString endTime=getTime.Format( "%H:%M:%S, %B %d, %Y" );
WriteLogFile(endTime);
.......................
Play() is a memeber function of class MyDirSound.. which plays the wave file.. The same code for writing time works fine with the recording of sound module ..
pallavi
|
|
|
|