Click here to Skip to main content
15,917,565 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generaltype "double" question Pin
DaveE9th9-Jul-03 4:11
DaveE9th9-Jul-03 4:11 
GeneralRe: type "double" question Pin
BoudewijnEctor9-Jul-03 4:14
BoudewijnEctor9-Jul-03 4:14 
GeneralRe: type "double" question Pin
DaveE9th9-Jul-03 4:25
DaveE9th9-Jul-03 4:25 
GeneralRe: type "double" question Pin
Cedric Moonen9-Jul-03 4:30
Cedric Moonen9-Jul-03 4:30 
GeneralRe: type "double" question Pin
David Crow9-Jul-03 4:34
David Crow9-Jul-03 4:34 
GeneralRe: type "double" question Pin
keegan9-Jul-03 4:19
keegan9-Jul-03 4:19 
GeneralRe: type "double" question Pin
Trollslayer9-Jul-03 4:23
mentorTrollslayer9-Jul-03 4:23 
GeneralRe: type "double" question Pin
DaveE9th9-Jul-03 4:32
DaveE9th9-Jul-03 4:32 
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
GeneralRe: type &quot;double&quot; question Pin
David Crow9-Jul-03 4:37
David Crow9-Jul-03 4:37 
GeneralRe: type &quot;double&quot; question Pin
Ryan Binns9-Jul-03 4:25
Ryan Binns9-Jul-03 4:25 
GeneralRe: type &quot;double&quot; question Pin
DaveE9th9-Jul-03 4:53
DaveE9th9-Jul-03 4:53 
GeneralNatural Language Processing open source Pin
JoeSox9-Jul-03 3:48
JoeSox9-Jul-03 3:48 
GeneralLoading ComboBox within a thread Pin
cycosi9-Jul-03 3:46
cycosi9-Jul-03 3:46 
GeneralRe: Loading ComboBox within a thread Pin
David Crow9-Jul-03 4:00
David Crow9-Jul-03 4:00 
GeneralCustom message in ClassWizzard Pin
Cedric Moonen9-Jul-03 3:23
Cedric Moonen9-Jul-03 3:23 
GeneralEasy question on DHTML Editing control Pin
Scozturk9-Jul-03 3:15
professionalScozturk9-Jul-03 3:15 
GeneralRe: Automatic overwriting in setup Pin
David Crow9-Jul-03 3:15
David Crow9-Jul-03 3:15 
GeneralInitialize a List Box Pin
Jay Hova9-Jul-03 2:46
Jay Hova9-Jul-03 2:46 
GeneralRe: Initialize a List Box Pin
Jay Hova9-Jul-03 2:52
Jay Hova9-Jul-03 2:52 
GeneralRe: Initialize a List Box Pin
keegan9-Jul-03 3:11
keegan9-Jul-03 3:11 
GeneralRe: Initialize a List Box Pin
David Crow9-Jul-03 3:13
David Crow9-Jul-03 3:13 
GeneralRe: Initialize a List Box Pin
Jay Hova9-Jul-03 3:55
Jay Hova9-Jul-03 3:55 
GeneralRe: Initialize a List Box Pin
David Crow9-Jul-03 4:02
David Crow9-Jul-03 4:02 
GeneralRe: Initialize a List Box Pin
Jay Hova9-Jul-03 6:31
Jay Hova9-Jul-03 6:31 
GeneralRe: Initialize a List Box Pin
David Crow9-Jul-03 8:16
David Crow9-Jul-03 8:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.