|
The size of a double is 8 bytes. Use the sizeof(double) to see that your self. I have no clue why you would want to do this. Also if you don't pack the data using #pragma pack(push,1) before your struct and #pragma pack(pop) after your struct you will get unexpected results.
John
|
|
|
|
|
I have used type "double" for the elements in my array. My numbers are 10 digits long, so I can't use the int type. My numbers don't have any decimals in them, but the output from my program is displaying decimals on the monitor. eg. number 2647584936 will display as 2647584936.000000
How do I get rid of the decimal and the six zeros?
Thanks
|
|
|
|
|
No idea,
But i'd use the Int64 type instead of int. The max size of Int64 is 2^64 --> Seems big enough.
|
|
|
|
|
I tried to enter the "int64" data type into my VC++ 6.0 compiler, but it doesn't turn blue as do other valid prototypes. How do I implement the int64 data type? It sounds very interesting.
Thanks
|
|
|
|
|
Use long integer (long int) instead! This should work: range is:
–2,147,483,648 to 2,147,483,647 . Or you can even use unsigned long int if you don't need negative numbers.
|
|
|
|
|
It's a Microsoft-specific type, so you must preface it with two underscores.
|
|
|
|
|
look for SetPrecision on the msdn library.
or look here.[^]
*.*
|
|
|
|
|
User the correct type specifier in your print, e.g.
<br />
str.Format("%5.0f", d)
where str is a CString and d is the double variable.
Elaine
The tigress is here
|
|
|
|
|
Thanks Elaine, I was hoping you might show me how to apply the code you mentioned into my program below?
<br />
#include "stdio.h"<br />
#include "math.h"<br />
#include "iostream.h"<br />
#include "stdlib.h"<br />
<br />
<br />
double values[] = {<br />
1115364759770,<br />
3748596078661, <br />
3849573800596,<br />
3849573846696,<br />
4615243374995,<br />
4745520008574,<br />
4748020008574,<br />
4847020005584,<br />
4847020007584, <br />
5758020005007,<br />
5758020005287,<br />
7557030006574, <br />
7937030006574,<br />
9500020004758, <br />
9585520004758, <br />
};<br />
<br />
<br />
int compare (const void * a, const void * b)<br />
{<br />
#define ABS(a) ((a) < 0 ? -(a) : (a) ) <br />
double _a = *(double*)a; <br />
double _b = *(double*)b; <br />
if( ABS(_a - _b) < 0.00000001 ) <br />
return 0; <br />
else if( _a < _b)<br />
return -1; <br />
else <br />
return 1;<br />
}<br />
int main ()<br />
{ <br />
double * pItem; <br />
cout<<"please enter a number"<<endl; <br />
double key;<br />
cin>>key; <br />
pItem = (double*) bsearch (&key, values, 15, sizeof (double), compare); <br />
if (pItem!=NULL) <br />
printf ("%lf is in the array\n",*pItem);<br />
else <br />
printf ("%lf is not in the array\n",key); <br />
return 0;<br />
}<br />
Dave
|
|
|
|
|
printf("%.0f is in the array\n", *pItem);<br />
printf("%.0f is not in the array\n", key);
|
|
|
|
|
Instead of printing them with '%f' , print them with '%10.f' . This will get rid of the decimal point and the digits following it.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks everybody, the %10.f and %.0f worked great.
|
|
|
|
|
Does anyone know of any Natural Language Processing open source for
C++?
at this point in my search, I will take any suggestions, even a link to a free VB source nah forget that. But maybe Java.
I have posted a question to Google answers, and they are trying to find me one too but no answer yet
Hopefully someone here knows of something I could use for the NLP part for Carl v2 I am working on, currently. Thanks.
sorry for the repost but I thought I might be able to reach some more people
Later, JoeSox www.humanaiproject.org
"Dream as if you'll live forever; live as if you'll die tomorrow."
- James Dean(ISTP)
|
|
|
|
|
Hi
I have the following problem.
In my application, I have a window in which I have several comboboxes.
When accessing the data on the server to fill them, The application was really slowed down.
So I decided to have all the loading in a thread.
Meanwhile everything is loading, I set the text for the combos.
It is OK for all of them, except one, in which all the data inferior the the text disappear from the combo.
If I load the data out of the thread everything is fine.
Any idea??
|
|
|
|
|
So the primary thread, which owns the comboboxes, spawned a secondary thread.. Is that right? Does the secondary thread try to populate the comboboxes (if so, the secondary thread will need a message pump), or does it post a message back to the primary thread (if so, remember to use PostMessage() and not SendMessage())?
To eliminate the secondary thread as a culprit, comment out the code that creates it, and have the primary thread populate the comboboxes. If the problem persists, you know the secondary thread is not to blame.
|
|
|
|
|
Hi!
I have designed a custom control (a real-time chart) and I want to associated a function handler (in the class of the window wich uses the chart) when the user clicks on the legend. So, in the class of the custom control, I added a handler for the WM_LBUTTONDOWN message and I check there if the mouse is on the legend.
If yes, I send a message to the parent window but I want this custom message appear in the ClassWizzard (like for example: OnLegendClick).
Is such a thing possible and how to implement it ??
Thanks
|
|
|
|
|
Hi!
I am using the DHTML editng control to make a WYSIWYG application.
Well my problem is that I don't know how to insert some HTML tags into the code.
The dhtml editing control gives you some functions for fonts, style,alignement,etc... but the user may need to add tables too.
I want to put a button which will open a table configuration dialog... the dialog will put all the values in a string... ( I can do it until here) and it will put the generated html tags into the html code...
Can anyone help me?
Thank you very much for your future answers!
Well... I am a beginner ...
|
|
|
|
|
Why must they uninstall the whole application just to get an updated EXE? Just have them shut down the application prior to running the setup program.
|
|
|
|
|
Hi,
Still trying to get used to programming, and still need a little help. I asked a few questions yesterday about a texteditor, but since have changed my approach.
I wanted to know how to initialize a List Box to have text in it everytime the dialog starts up. Is this possible? If it is, is there a way to space out the text that I want to appear? I want it to look like this if possible:
Team1 Team 2 Team 3 Team 4
Thanks in advance!
|
|
|
|
|
Silly me....I got the text to come up.;P
Can anyone help with the formatting though?
Thanks again
|
|
|
|
|
what do you mean by 'formatting?' if youre trying to get strings into a listbox, you can use
My_List_Box.AddString("hello");
if you mean turning off alphabetical sorting of the contents of the listbox, in the resource editor, witht he listbox selected, look in the properties window and set the 'Sort' value to False (or off, depending).
is that what you mean?
*.*
|
|
|
|
|
How you want the data formatted will govern whether you want/need to use a list box, list control, or a grid control.
Although it's possible to make a list box look like it has columns, it remains a one-column control that uses tab stops to separate the columns.
|
|
|
|
|
Sorry for not being clear...
I would like to have the words spaced out in the line of text. Just so that it is easier to read. I want it so that I do not have to manually hit the space bar between the words that i am gonna enter. Some of the information going on the lines are spaced further in that another like in the chart below.
Ideally I want my dialog box to look exactly like this:
Team 1 Team 2 Team 3 Team 4
Game 1 80 69
Game 2 79 70
Game 3 55 73
Game 4 73 82
Player #22 from Team 3 is the MVP of the tournament.
He lead the team in points, rebounds, assists and steals.
He also led the tournament in points (33.2), assists (8.9), and steals (3.2)
I thought about using a list control, but i couldn't get the last 3 sentences to appear across the columns.
THANKS IN ADVANCE!!!
|
|
|
|
|
Use an edit control with a fixed-space font.
|
|
|
|
|
Hi,
I am really new to programming, and do not fully understand how to do this. (The fix spaced font)
Can you possible give more details on how to do this? Will this get my "table" to look exactly how i want it?
Thanks again. Sorry for being slow with this. Mechanical Engineers are not the best programmers!
|
|
|
|