Click here to Skip to main content
16,008,942 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Matrices Pin
imsniper23-Apr-03 0:00
imsniper23-Apr-03 0:00 
GeneralRe: Matrices Pin
Albedo23-Apr-03 3:29
Albedo23-Apr-03 3:29 
GeneralRe: Matrices Pin
David Chamberlain23-Apr-03 9:28
David Chamberlain23-Apr-03 9:28 
GeneralData packing libraries Pin
progman22-Apr-03 13:50
progman22-Apr-03 13:50 
GeneralRe: Data packing libraries Pin
imsniper23-Apr-03 21:34
imsniper23-Apr-03 21:34 
GeneralProblem drawing icon with shadow in XP Pin
Mathias S.22-Apr-03 13:22
Mathias S.22-Apr-03 13:22 
GeneralRe: Problem drawing icon with shadow in XP - Solved! Pin
Mathias S.22-Apr-03 22:29
Mathias S.22-Apr-03 22:29 
Generalfloat number comparision Pin
act_x22-Apr-03 11:52
act_x22-Apr-03 11:52 
I am computing average of some readings. For each reading I am taking n samples .
My steps are 0 , 0.5, 1.0 .... till 4.5 after which the increments are smaller like 4.5, 4.6,4.7,4.8...
I am doing the following comparision


float vin ;<br />
float x;<br />
loop <br />
if((vin==x) ){<br />
Compute sum for this vin value ; i.e sum  =sum + newValue <br />
samples++<br />
}<br />
else{<br />
// if new set of readings have begun and we need to calculate average  for  this reading <br />
    if(vin!=x ){<br />
	sampleArray[sampleCount].thisAverage=sum/(samples);<br />
	sampleCount++;<br />
	if(x>4.5)<br />
           // we need finer increment after 4.5 <br />
	   vin+= 0.10000;				<br />
        else<br />
	   vin+=0.5;<br />
				<br />
	samples=1;<br />
	}<br />
}


What I am observing is this
everything works Okay until vin reaches 4.80000
There is a comparision done as shown in code above

if((vin==x) ){<br />
Compute sum for this vin value ; i.e sum  =sum + newValue <br />
samples++<br />
}


using debug I am able to see that both vin and x are 4.80000 but
the expression (vin==x)evaluates to 0 and the "else" code kicks in !!!


definately there is something weird going in here which I am unable to grab ! I need some help understanding this !!! Please help
GeneralRe: float number comparision Pin
Maximilien22-Apr-03 12:03
Maximilien22-Apr-03 12:03 
GeneralRe: float number comparision Pin
Anonymous22-Apr-03 12:21
Anonymous22-Apr-03 12:21 
GeneralRe: float number comparision Pin
Phil Hamer22-Apr-03 16:09
Phil Hamer22-Apr-03 16:09 
GeneralRe: float number comparision Pin
Anonymous22-Apr-03 16:03
Anonymous22-Apr-03 16:03 
GeneralOnContextMenu Shows up without text Pin
allcodeluver22-Apr-03 11:14
allcodeluver22-Apr-03 11:14 
GeneralRe: OnContextMenu Shows up without text Pin
valikac22-Apr-03 11:56
valikac22-Apr-03 11:56 
GeneralRe: OnContextMenu Shows up without text Pin
allcodeluver23-Apr-03 4:26
allcodeluver23-Apr-03 4:26 
GeneralWinsock Problems Pin
Ken Mazaika22-Apr-03 10:51
Ken Mazaika22-Apr-03 10:51 
GeneralRe: Winsock Problems Pin
valikac22-Apr-03 11:59
valikac22-Apr-03 11:59 
GeneralRe: Winsock Problems Pin
Ken Mazaika22-Apr-03 13:28
Ken Mazaika22-Apr-03 13:28 
GeneralRe: Winsock Problems Pin
valikac22-Apr-03 14:29
valikac22-Apr-03 14:29 
GeneralRe: Winsock Problems Pin
basementman24-Apr-03 8:10
basementman24-Apr-03 8:10 
GeneralXP Style dialogs Pin
conetti22-Apr-03 10:39
conetti22-Apr-03 10:39 
GeneralRe: XP Style dialogs Pin
Neville Franks22-Apr-03 11:40
Neville Franks22-Apr-03 11:40 
GeneralDouble Click Pin
Anthony988722-Apr-03 10:16
Anthony988722-Apr-03 10:16 
GeneralRe: Double Click Pin
David Crow22-Apr-03 10:22
David Crow22-Apr-03 10:22 
GeneralCreateCompatibleBitmap Pin
georgiek5022-Apr-03 10:13
georgiek5022-Apr-03 10:13 

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.