|
Of course but when you are dealing with high precision numbers, you have to implement workarounds to solve the problem.
I was just wondering how others have handled it. You simply cannot leave it like that when dealing with mathematical engines written in c++. The error will carry through and get worse. So I just wanted to see what others are doing.
For your information, the c# compiler does solve the problem and does give you to correct base 10 answer of .30
George W
Software Developer
www.zsystems.ca
|
|
|
|
|
IGeorgeI wrote: For your information, the c# compiler does solve the problem and does give you to correct base 10 answer of .30
Perhaps it makes use of some sort of epsilon value. See here for more.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
IGeorgeI wrote: For your information, the c# compiler does solve the problem and does give you to correct base 10 answer of .30
First, this isn't a C# forum.
Second, If you're doing this in C++, you're going to have to write some code to "fix" it. Write yourself a rounding function that will round to the nearest whole number. It ain't rocket science.
Third, you're arguing with someone that's trying to help you. Not very smart, even for a C# programmer.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I am not a C# programmer by trade. I am a C/C++/Java/MFC developer.
1) I posted my C++ question in the C++ section of this forum. I merely added the fact about the C# compiler to help other people. You must have misunderstood my post.
2)I have written work arounds for this problem, I just wanted to see how other people have handled this problem out of pure interest. We can all become better programmers if we want to. You must have misunderstood my post.
3) At no point was I arguing with him. Why would I argue with somebody who is clearly trying to help me?? You must have misunderstood my post.
I would suggest that in the future you should try reading the post more closely to avoid misunderstandings like this. If you want, you can contact me anytime and I will help you with that.
Kindest Regards
George W
Software Developer
www.zsystems.ca
|
|
|
|
|
IGeorgeI wrote: I was just wondering how some of you have solved this problem.
add a tiny amount to the result of the division, then truncate. aka. 'round up'
yes, it biases the results in one direction, but them's the breaks.
|
|
|
|
|
First of all I want to state that I have read the other posts and would have ignored that one about C#. This is not a compiler specific problem, it is a hardware problem and I do not know any solution. Although there is an excellent book called “Numerical Recipes in …” (very old now) that probably addresses these issues. If Microsoft has introduced a way to solve it, via software, they have not been vocal about it. The only thing I can think of is rounding up when you see all those ‘9’s’.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
When I try to set the tab stops in a CEdit control using the SetTabStops(int numberofstops, LPINT tabstops) method, they don't get set properly and they appear different on two different Win XP-Pro computers. I set them to 64, 64, 64, 32, 32, 32, 32 and on one computer get the first one at 64, and the rest at 32. The other gives me the first at 64 and the remaining ones packed together.
Any ideas on what I'm doing wrong?
|
|
|
|
|
Bill Brocklebank wrote: ...they appear different on two different Win XP-Pro computers.
Nothing wrong with that since DLUs are machine, or rather, current system font, dependent.
That aside, wouldn't you need to use 64, 128, 192, 224, 256, 288, and 320?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: That aside, wouldn't you need to use 64, 128, 192, 224, 256, 288, and 320?
Actually, according to the MFC documentation, each value represents an offset from the preceding position.
int tabs[3] = {8, 8, 8};
Results in tab positions of 8, 16, 24.
I am still thinking about the unexpected format displaying problem.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Thanks. David is right. The documentation is ambiguous and I was interpreting it like John. Works fine now on the laptop I brought home. Should also work back at the office Monday.
Still doesn't explain the differences in the displays. It must be related to the display size (laptop is 1024x768 - it was packing down the data, desktop at work is 1200x900). But if they both work now, I'm happy.
Thanks again.
|
|
|
|
|
John R. Shaw wrote: Actually, according to the MFC documentation, each value represents an offset from the preceding position.
Did you get that from here?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
David,
I made a mistake; I agreed with you and then ask MFC help to check in case I was wrong. I did not realize that it was giving me the description of StringFormat::SetTabStops instead of CEditView::SetTabStops.
“Each tab-stop offset in the tabStops array, except the first one, is relative to the previous one. The first tab-stop offset is relative to the initial offset position specified by firstTabOffset. For example, if the initial offset position is 8 and the first tab-stop offset is 50, then the first tab stop is at position 58. If the initial offset position is zero, then the first tab-stop offset is relative to position 0, the string origin.”
Oh well, that is what happens when you get out of practice.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hi,
I need to know how to draw the checkbox button text background transparent.
Thanks
|
|
|
|
|
You could try the usual tricks - the WS_EX_TRANSPARENT flag, handling WM_ERASEBKGND, etc.
but I suspect they won't work on checkboxes.
You can always render the text yourself
|
|
|
|
|
Hi,
I have tried to handle WM_ERASEBKGND and I have also set WS_EX_TRANSPARENT for my CButton derived control, but the background still is not transparent.
How can I render the text only? I don't want to draw the box and the checkmark myself.
Thanks
|
|
|
|
|
Yeah... most, if not all, of the standard controls use opaque background on their text.
You can draw it yourself using something like DrawText(). Obtain the checkbox rect in
OnInitDialog() and set the controls text to an empty string (you could get the text first so you
have the text string). In OnPaint(), call the base class OnPaint() then get a DC for the window
and select a pen of the text color into it, set its background mode to transparent, and use
DrawText() to render the string.
The Microsoft recommended method is owner draw.
Mark
|
|
|
|
|
Did you try it with ON_WM_CTLCOLOR_REFLECT ?
for my purposes, it worked...
<br />
class CTransparentCheckbox : public CButton<br />
{<br />
public:<br />
CTransparentCheckbox();<br />
<br />
virtual ~CTransparentCheckbox();<br />
protected:<br />
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);<br />
DECLARE_MESSAGE_MAP()<br />
};<br />
<br />
<br />
CTransparentCheckbox::CTransparentCheckbox()<br />
{<br />
}<br />
CTransparentCheckbox::~CTransparentCheckbox()<br />
{<br />
}<br />
BEGIN_MESSAGE_MAP(CTransparentCheckbox, CButton)<br />
ON_WM_CTLCOLOR_REFLECT()<br />
END_MESSAGE_MAP()<br />
<br />
HBRUSH CTransparentCheckbox::CtlColor(CDC* pDC, UINT nCtlColor) <br />
{ <br />
ASSERT(nCtlColor == CTLCOLOR_STATIC);<br />
pDC->SetBkMode(TRANSPARENT);<br />
return (HBRUSH)GetStockObject(NULL_BRUSH);<br />
}
greetings,
ralf.
|
|
|
|
|
Hi Ralf,
your tip works perfectly for me! Thank you very much !!!
Greetings
|
|
|
|
|
Hi,
I am developing a dll which uses NetUserGetInfo to retreive the home directory of a Domain user.
NetUserGetInfo returns 1008 error code.
my usage of function:
NetUserGetInfo(Domain-server,domain-user,11,buf)
The problem i was thinking was, The dll is launched by a local user(admin privilages) on a system which is in the same domain. SO may be the local user does not have enough permissions to use the NetUserGetInfo function to retreive the necessary information.
My questions:
1. Is it possible to provide enough permissions for the local-user, How?
2. The other alternate is to connect to domain-server with some power user and then use the NetUserGetInfo function. But I do not find suitable function to connect to domain server with a power user credentials in windows network management API(netapi32.lib)
Thanks for the help
|
|
|
|
|
gbabu17 wrote: NetUserGetInfo returns 1008 error code.
Which is ERROR_NO_TOKEN .
What are Domain-server , domain-user , and buf ?
Do you have UNICODE and _UNICODE defined?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
they are passed to the function correctly, because i am printing them just before passing to the NetUserGetInfo.
|
|
|
|
|
gbabu17 wrote: they are passed to the function correctly...
But are they wchar_t or TCHAR types?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
They are wchar_t types.
i think it is something related to permissions(may be ACL) but i cannot figure it out.
thanks
|
|
|
|
|
In the MSDN-documentation for the InitializeCriticalSection-function it says :
In low memory situations, InitializeCriticalSection can raise a STATUS_NO_MEMORY exception.
Now, what exactly do i have to catch here ?! Couldn't find any hint anywhere.
|
|
|
|
|
Mr.Brainley wrote: Now, what exactly do i have to catch here ?!
There's nothing to catch.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|