|
HI,
I was developed the source code for time and frequency calculation.
i put two text boxes one for time value another for frequency value.
Both are float data type.
formula is :- frequency = 1 / time * 1000
and also Time =1 / frequency * 1000;
In Time text box kill focus event this( frequency = 1 / time * 1000 ) formula work properly and show one answer in float value in frequency text box.
but
In frequency text box kill focus event (Time =1 / frequency * 1000) formula did not work properly.
ex:
i put 1550 in time text box
answer 0.545161 is shown on frequency text box
then i move the cursor in to reverse ie, time text box it display 1550.000732 instead of 1550.
any body solve my problem as quick as early.
Thanking you.
vivek
|
|
|
|
|
HAI,
I was developed the source code for time and frequency calculation.
i put two text boxes one for time value another for frequency value.
Both are float data type.
formula is :- frequency = 1 / time * 1000
and also Time =1 / frequency * 1000;
In Time text box kill focus event this( frequency = 1 / time * 1000 ) formula work properly and show one answer in float value in frequency text box.
but
In frequency text box kill focus event (Time =1 / frequency * 1000) formula did not work properly.
ex:
i put 1550 in time textbox
answer 0.545161 is shown on frequency text box
then i move the cursor in to reverse ie, time text box it display 1550.000732 instead of 1550.
any body solve my problem as quick as early.
Thanking you.
vivek
|
|
|
|
|
Please delete your two other messages.
This is not an error, it is due to floating point precision. Just don't print the decimals you don't need in the text box.
|
|
|
|
|
use trunc to quit decimals without rounding, or floor to round always down.
Is something annoying, I had it as well and didn't find a way to do it but this one.
BTW:
1 / 1550 * 1000 = 0,64516129032258064516129032258065 and not 0,54516
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
hi all
I use vs6
I have to find a way to change the default language of WinXP/Win2K
I can get the default language by use function GetSystemDefaultLCID.
if the return val of GetSystemDefaultLCID != 1037
i have to change it to 1037.
Is some one know the way.
TNX
|
|
|
|
|
This seems to be interesting. Have you achieved this? I could not find a solution immediately.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->ßRÅhmmÃ<-·´¯`·.
|
|
|
|
|
no, if you can think about any solution i be glad to see that.
TNX
|
|
|
|
|
Hi All,
I'm got an interesting problem and I'm trying to think of the best way to get around it.
I've got to import some data into structs held currently held in a std::vector. It's basically 3D position data. My struct looks something like this:
struct vertex<br />
{<br />
float x;<br />
float y;<br />
float z;<br />
}
Now, when I read in the data from the file I am going to get a lot of duplicate values, i.e. a vertex where x,y & z match an already existing point.
What I'd like to do is something like this:
- Read x,y,z from file.
- Check if vertex struct with those three values already exists in the vector.
- If yes, return the index in the vector that points to the existing record.
- If no, insert a new vertex record with the values and return it's index.
The issue I'm having is how to quickly determine if the values are already in there. The simpliest solution would be for every value read from the file, loop through the vector start-to-end looking for it.
However, we could be looking at an insane ammount of data here and I can see this getting slower and slower as the vector gets larger and larger.
Can anyone recommend a solution?
- Jed
|
|
|
|
|
NJed wrote: Can anyone recommend a solution?
Keep them in a hash-set instead (you'll need to supply your own operator == ) and if the order is important, keep the pointers to them in a vector.
|
|
|
|
|
Could you point me to an example? I can't say I've ever used a hash before.
- Jed
|
|
|
|
|
Or just make your own validation methode before saving.
BOOL CYourClass::ValidateVertex (vertex vData, int ArrayLimit)
{
int nError = 0;
for (int = 0; i < ArrayLimit; i++)
{
if ((m_YourVector[i].x == vData.x) && (m_YourVector[i].y == vData.y) && (m_YourVector[i].z == vData.z))
{
nError++;
break;
}
}
;
if (nError)
return FALSE;
;
return TRUE;
}
;
;
do
{
if (ValidateVertex (vNowReading, nAlreadySavedVertex))
{ SaveTheDataAtTheEndOfYourVector (vNowReading);
nAlreadySavedVertex++;
}
} while (FileNotEnded);
Or something like this.
BTW if you dont know a priori how large the vector is going to be, because of repetitions... would not be better to use a list instead a vector ??
The only and biggest problem... if there are a LOT of data... the validation will take longer as the saved data amount increases. But this should be always the same, no matter which methode you use.
Hope it helps
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Hi all,
Is there any specific property in rich edit control so that by enabling it only we can enter text in that in second/third.. line succesively by pressing enter key.Actually while getting the dialog box run i am able to get the functionality of ENTER key in Rich edit control but when i am running the project i am not able to get the functionality of ENTER key.Is there any specific reason for this.
Please guide regarding this.
Regards,
Mayank
|
|
|
|
|
Are you talking about the ES_WANTRETURN style?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
And also see PreTranslateMessage .
|
|
|
|
|
Hi all,
I am trying to print size of my file in a list control using this code
int len = finder.GetLength();
char *len_str = new char;
sprintf(len_str,"%d",len);
m_Files.SetItemText(i,1,len_str);
but it gives this error
error C2664: 'CListCtrl::SetItemText' : cannot convert parameter 3 from 'char *' to 'LPCTSTR'
i am using VC-2005
can anybosy tell me how to resolve this problem
|
|
|
|
|
Don't use a char pointer but a TCHAR pointer (which is a macro that resolves to wchar if UNICODE is defined or to char if UNICODE is not defined). And use _stprintf instead of sprintf.
You also forgot to create an array of the correct size.
int len = finder.GetLength();
TCHAR *len_str = new TCHAR[len];
_stprintf(len_str,_T("%d"),len);
m_Files.SetItemText(i,1,len_str);
EDIT: don't forget to delete[] the buffer once you are done with it.
|
|
|
|
|
I think you should use swprintf instead of stprintf
dlfkgj lsdfkglfkgjlfgl jldfk fldkk jk
|
|
|
|
|
No, stprintf is a macro that resolves to sprintf if UNICODE is not declared or to swprintf if UNICODE is declared. So your code still compiles even if you change unicode settings.
|
|
|
|
|
Since len is apparently the length of a file, you won't need to allocate your buffer that big, but you will need enough characters to hold all the digits.
int len = finder.GetLength();
TCHAR *len_str = new TCHAR[(int)(log10(len) + 2)];
_stprintf(len_str,_T("%d"),(int)(log10(len) + 2));
m_Files.SetItemText(i,1,len_str);
delete[] len_str;
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Yes that's right, I didn't think too much before posting my reply .
But you should print the len in the string, not the number of characters
|
|
|
|
|
You're right about the len in the printed string - my turn to not think clearly about what he's doing!
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
I understand the point, but maybe it would be nice to avoid both continuos allocation/deallocation of memory and use of the log10 . Simply allocate once a (relatively) big buffer on the stack.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Well, perhaps that would be ok, but if the file size is large (2 GB) the new of a 2GB char array would probably fail, and you don't need anywhere near that many characters to hold a file size.
Perhaps a fixed buffer size of say [MAX_PATH_LEN] (which is 256) would be more than enough characters to hold any file size.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
krmed wrote: Well, perhaps that would be ok, but if the file size is large (2 GB) the new of a 2GB char array would probably fail, and you don't need anywhere near that many characters to hold a file size.
Of course the buffer can't be sized equal to file dimension, have you missed my aknowledge about your point?
That stated, my post completely agree with your bottom line:
krmed wrote: Perhaps a fixed buffer size of say [MAX_PATH_LEN] (which is 256) would be more than enough characters to hold any file size.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Sorry if you thought I meant that all at you.
Actually, I was agreeing with the fixed size, but wanted the OP to realize that he probably can't new a char array the size of the file length (and it wouldn't be needed anyway).
I was simply suggesting that a fixed size (like you said) would work, and MAX_PATH_LEN would be more than enough - in fact 20 characters will hold more than ever needed.
Have a great day!
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|