|
Shikha Jain wrote: ...it is not asked that what index does getcursel() return to me...
Actually, you did. However, if that's not what you meant to ask, please rephrase your question.
Shikha Jain wrote: ...i want the combobox to get update...
Populate a combobox using either AddString() or InsertString() .
Shikha Jain wrote: ...current item which get selected in the ListBox .
Which is obtained with GetText() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
We are working on a scientifical related product which is most sensitive towards mathematical functions (even 7th decimal place chang can cause considereble differences in the output values). We’ve observed that the trignometric functions are behaving differently in Visual C++ 2003 and Visual C++ 2005 versions. We've recently upgraded IDE from VS2003 to VS2005 and compiled the unmanaged vc++ code in both versions.
To explain this in detail, please consider the following console application and please compile it in both 2003 and 2005 versions.
// CosSinDemo.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <math.h>
const float PI = 3.1415926535f;
const float PI_OVER_180 = PI / 180.0f;
int _tmain(int argc, _TCHAR* argv[])
{
static double fDummy1 = 0;
static double fDummy2 = 0;
float fDiffLat = -0.19629669; //input values to cos()
float fDiffLon = 0.060424805;
fDummy1 = cos( fDiffLon * PI_OVER_180);
fDummy2 = cos( -fDiffLat* PI_OVER_180);
printf("fDummy1 - %3.20f\nfDummy2 - %3.20f", fDummy1, fDummy2);
return 0;
}
output with VS2005:
fDummy1 - 0.99999946355819702000
fDummy2 - 0.99999415874481201000
output with VS2003:
fDummy1 - 0.99999944389707407000
fDummy2 - 0.99999413118713976000
The values are differing in 7th decimal place. Could you please someone help me out on how to make VS2005 cos/sin functions behave same as was there in 2003 version.
cheers,
PraK
|
|
|
|
|
If you're that worried about accuracy, why are you using float and not double ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
thanks for your reply, yes that is true, with 'double' data type the behaviour of cos/sin functions is same, but the system which was compiled with VS2003 has been already released and now we are trying to see the possibility of getting consistency in the system when compiled with VS2005. once again thanks for your time.
PraK
|
|
|
|
|
prakash reddy wrote: float fDiffLat = -0.19629669; //input values to cos()
float fDiffLon = 0.060424805;
As CG has already indicated, float s only have 6-7 significant digits. Use double s for 15-16 significant digits.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi everyone,
on my Dialog i have multiple components for example a label with a textbox a side
If i resize the CFormView ( Not the dialog -> MDI Project ) the event reacts each pixel.
How can i center the label with the textbox a side ?
My only idea is to get the position of the component and to move the LEFT (re-setting) one pixel farer.
Next event the RIGHT one pixel farer...
But aren't there more possibilities to center components?
many thanks
|
|
|
|
|
The only way to position something is to set it's position yourself, in code. Handle the WM_SIZE event.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
S*** .. ok thanks
Before i started the hard way, i would ask about another possibility
|
|
|
|
|
Sure - there are better options in .NET, but not in MFC.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi, I am working on VC++ 2003. I am using a string as "char *pchData;". now at some point how can I check that 'pchData' is defined or undefined?
Thanks in advance
|
|
|
|
|
Your code is wrong. NEVER create a pointer without setting it to a valid value, or NULL. Then, just check if it is NULL.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
If you're unsure whether a particular pointer is pointing at a valid address, then something's wrong with your design. In C/C++ it's the program's responsibility to make sure that pointers are either NULL or contain a valid address.
The IsBadXxxPointer() APIs are not reliable (search MS blogs for them, you'll find a few posts about how evil they are).
|
|
|
|
|
We have an application that was written on VC++ 6.0 a few years ago. Today a customer reported that it did not work on their 64 bit laptop (that's all they said 'it doesn't work'!). We are waiting for more info on the problem and we don't have a 64 bit system to try it on.
I just wondered, has anyone had any experience running 32 bit apps on 64 bit machines? Good / bad etc?
Many Thanks,
Ali
|
|
|
|
|
|
Thanks, I will take look at that - sounds like just what I need.
Regards,
Ali
|
|
|
|
|
The first thing that comes to mind is that a 32-bit EXE can't load 64-bit DLLs and vice-versa. For example, a 32-bit IE plugin won't load in 64-bit IE. But without any details, we can only give you WAGs.
|
|
|
|
|
Michael Dunn wrote: we can only give you WAGs.
Fair comment, just checking out the general opinion. I thought a 32bit exe would run on a 64bit machine using WOW, and wondered if anyone else has had any trouble - looks like they haven't - its just my customer!
Thanks Anyway,
Ali
|
|
|
|
|
Alison Pentland wrote: I thought a 32bit exe would run on a 64bit machine using WOW
It can, you just can't mix 32 and 64 bit modules in the same process.
|
|
|
|
|
rand() returns an integer in the range [0 - RAND_MAX]. What if I want to generate random integers in a wider range? is there no escape from calling rand() twice and then multiplying the results?
Is there a continuous random number generator in C++ ?
Thanks,
Avi.
|
|
|
|
|
avimitrani wrote: is there no escape from calling rand() twice and then multiplying the results?
That's not really random, nor does it give a wide enough range. Try calling it twice and shifting the first result to take the bits above the second result.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You could generate a random number between 0 and 1, then multiply that by the bigger number you want to use, e.g.
flaot fRand = rand() / (float)RAND_MAX;
int iValue = fRand * 10000000;
|
|
|
|
|
That won't work: some values might have no chances at all to be picked.
|
|
|
|
|
|
avimitrani wrote: What if I want to generate random integers in a wider range?
You'll need to roll your own. Something like this.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
Iam new to vc++ programming.. iam writing an application which needs some functionalities of some of the activex dlls that I have. Previously static linking to the lib file is done. But right now i need to load active x dlls at runtime. Iam not getting how to instantiate the libraries and loading it at runtime. My platform is Visual Studo 6.0..Can anyone of you help me regarding this. Any help will be appreciated.....
thanks
Bollapalli
bollapalli
|
|
|
|