|
Hi John,
I think to calculate the number of trailing 0s is an algorithm problem, why you say it is a display problem -- we can calculate the number without displaying it, right?
regards,
George
|
|
|
|
|
Hi George,
I was answering an email when I received your reply. I did not say the number of zeros was a display problem. I said the number of zeros following any number is infinite, which means you can display as many as you want. If you want to run an algorithm to display all the zeros following any number, then go ahead. Just remember that the machine will never stop printing zeros until you stop it or turn it off. It is a matter of how many zeros you want to display. I know there are some functions (algorithms) that will print a ridiculously high number of trailing zeros, but that is the designer’s choice. The normal problem for those using it is to trim all those unnecessary zeros before displaying it to the user. Trailing zeros are not really part of the number as they are a given. If a number has a hundred zeros following it and they end with a 1 then they are not trailing zeros, but any zeros following the 1 are.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hi John,
I do not want to print the 0s. I want to print the number of 0s. For example, if the input is 5, then output is 1 (5! = 120), if the input is 3, the output is 0 (3! = 6).
regards,
George
|
|
|
|
|
I apparently do not understand the original question. I am not a mathematician and have forgotten most of my advanced math a long time ago. I thought we where dealing with trailing zeros which is the same in code as it is in mathematics. What you are showing me does not make since to me from a coding point of view. For some reason you have my attention, but to be honest I do not know what you are talking about. If you find an answer and remember me, please do not hesitate to send it to me via codeproject.
Well goodnight now, it is about 8 hours passed my bed time.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Thank you all the same, John! Have a good night.
regards,
George
|
|
|
|
|
Do you want the number of digits of the number of 0's. i.e.
4! = 4x3x2x1 = 24 = 2 digits; but no zeros.
If you want the number of digits use log (base 10). I believe it's called log10 .
Steve
|
|
|
|
|
Hi Steve,
Log10 is not working -- it only checks the length of a digit in base 10 -- not the number of trailing 0s.
regards,
George
|
|
|
|
|
I see; you literally want the number of trailing 0's and not the number of digits. It's an interesting question.
Steve
|
|
|
|
|
Hi Steve,
You are right. If you have any further comments or ideas, please post here. I am happy to discuss with you again.
regards,
George
|
|
|
|
|
When i opened my project...the dialog displays as
"Cannot access classview information file.Classview information will not be available".
Wats wrong in my project?
I delete my .clw file and rebuild the project.The same problem exists.
|
|
|
|
|
This may some time happen. Either you may be having your project open somewhere else or you are not closing the application properly. Anyways you can try the procedure given below.
Delete the .ncb file that exists in your application.
Go to the Task Manager and close all running instances of MSDEV or .NET
Open Your project with the .dsw or .sln extension.
RebuildAll.
Does this solve your problem. If not you need to create a new workspace and add your existing files to it.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
how to convert my program to unicode
|
|
|
|
|
Lots of stuff here[^].
0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall.
Awasu 2.2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
|
|
|
|
|
Hi !!!
There are few rules:
1. you have to define _UNICODE, if you have precompiled headers file, define this there
2. you have to use _T("some text") macro for strings instead of "some text"
3. you have to use TCHAR instead of char
4. for console input/output you must use wcin , wcout, wcerr instead of cin, cout, cerr
5. you have to use std::string class with TCHAR instead of char
You can do this:
typedef std::basic_string<tchar> string;
I hope I helped you !
By !!!
-:KNOX:-
|
|
|
|
|
I have created a splitter window inside another splitter window.
In the newly created splitter window pane, a tree control is placed.
Upon selecting an item in the tree control, i want third splitter window to get created. But i am not able to get it done.
Before selecting the item:
first pane
---------------------------
tree|
ctrl| second pane
pane|
After selecting the tree item:
first pane
-----------------------------
tree | I-II pane
ctrl |--------------------
pane | II-II pane
Any body plz give me an idea.
Thanks in advance.
|
|
|
|
|
u cannot create a third splitter window by selecting an treectrl item bcoz this splitter window will initialize in oncreateclient and it will call only once.
|
|
|
|
|
U cannot create a third splitter window by selecting an treectrl item bcoz this splitter window will initialize in oncreateclient and it will call only once.
What u can do is
create this third window in the oncreateclient only but set its width to 1( you cannot set the width to 0 in MFC) and when you select the tree control once again set the width of third window to desired size.
To set the width you can use SetRowInfo() and SetColInfo()(please refer MSDN
for more help about SetRowInfo() and SetColInfo())
Rakesh
-- modified at 5:53 Saturday 3rd June, 2006
|
|
|
|
|
I getting an exception.
This is what i did in my code:
CMainFrame::OnCreateClient(..)
{
m_wndSplitter.CreateStatic( this,1,2);
m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CMyTree),CSize(200,100),pContext);
m_wndSplitter1.CreateStatic(&m_wndSplitter,1,2,WS_CHILD | WS_VISIBLE | WS_BORDER,m_wndSplitter.IdFromRowCol(0,1));
m_wndSplitter1.CreateView(0,0,RUNTIME_CLASS(CMyView1),CSize(200,100),pContext);
m_wndSplitter1.CreateView(0,1,RUNTIME_CLASS(CMyView1),CSize(400,200),pContext);
m_wndSplitter2.CreateStatic(&m_wndSplitter1,1,2,WS_CHILD | WS_VISIBLE | WS_BORDER,m_wndSplitter.IdFromRowCol(0,1));
m_wndSplitter2.SetRowInfo(0,1,1);
m_wndSplitter2.SetColumnInfo(0,1,1);
m_wndSplitter2.SetColumnInfo(1,1,1);
pCon=*pContext;
.....
}
In tree control view:
void CMyTree::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
CMultiSplitWndApp* app=(CMultiSplitWndApp*)AfxGetApp();
HTREEITEM sel=pNMTreeView->itemNew.hItem;
CString str= GetTreeCtrl().GetItemText(sel);
CMainFrame* wnd=(CMainFrame*)app->m_pMainWnd;
wnd->m_wndSplitter1.DeleteView(0,1);
wnd->m_wndSplitter2.SetColumnInfo(0,400,100);
wnd->m_wndSplitter2.SetColumnInfo(1,400,100);
wnd->m_wndSplitter2.SetRowInfo(0,400,100);
wnd->m_wndSplitter2.CreateView(0,1,RUNTIME_CLASSCMyTree),CSize (400,200),&wnd->pCon);
wnd->m_wndSplitter2.CreateView(0,1,RUNTIME_CLASS(CMyTree),CSize(400,200),&wnd->pCon);
*pResult = 0;
}
Correct me if there is any wrong.
Thanks for ur reply.
|
|
|
|
|
Hi
I think the reason why u r getting an exception is that
void CMyTree::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
..........
.............
wnd->m_wndSplitter1.DeleteView(0,1);
.......
.......
}
you have splitted the m_wndSplitter1 view into 1 row 2 col. Now while deleting you are writing
wnd->m_wndSplitter1.DeleteView(0,1);
which delets view assigned to one window only and second window is still having the view with it. So when you try to assign the view to this window you get an exception.
Insted you try
wnd->m_wndSplitter2.DeleteView(0,0);
wnd->m_wndSplitter2.DeleteView(0,1);
and then try to reassign the views.
Rakesh
|
|
|
|
|
Thanks for ur reply.
But still i am gettinmg an exception.
|
|
|
|
|
Sorry then,thats all from my side...
Will update you if I find any help on this issue...
Rakesh
|
|
|
|
|
Thankyou.
|
|
|
|
|
Hello,
I found some interesting facts about CSplitterWnd::CreateView(). The document says that you cannot call the 'CreateView()' from outside the OnCreateClient(). But you can call it indirectly from OnCreateClient() i.e. you can call another function from OnCreateClient() which calls CreateView().
________________________________________________________
For example....
OnCreateClient(..)
{
CreateAllViews(..)
}
CreateAllViews(..)
{
CreateView(...);
CreateView(...);
}
______________________________________________
In your code you are calling CreatView() in
void CMyTree::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult).
I think this might be the reason why you get an exception.....
Rakesh
|
|
|
|
|
I write code to communicaton between PC and microcontroller by serial port. I use CreateFile,WriteFile,ReadFile,...and program only use lines Tx,Rx of COM port, program run ok. But now I want to Set/Clear and read status of other lines (pins) of COM port: DTR,DSR,DCD,....
How to do that ?
Pls help me !
Thank !
|
|
|
|
|
I down a example (gridctrl_demo225) to study. in the code one thing puzzled me.
platform : VC.Net
a CGridCtrl based on CWnd,
a Dialog(CDlgA) is the parent of the CGridCtrl instance.
following is a part of the code
// EFW - Added to forward right click to parent so that a context
// menu can be shown without deriving a new grid class.
void CGridCtrl::OnRButtonUp(UINT nFlags, CPoint point)
{
CWnd::OnRButtonUp(nFlags, point); // !!!this call trigers CDlgA::OnContextMenu(...)
:
:
}
I read document of CWnd::OnRButtonUp(nFlags, point), it does not say, it will triger parent's OnContextMenu. so if I say CWnd::OnRButtonUp(nFlags, point) calls parent's OnContextMenu(...). Is it right?
And the weird thing is I set a breakpoint in CDlgA::OnContextMenu(...) want to see who calls it. There is no records of callstack.
|
|
|
|
|