Click here to Skip to main content
15,906,285 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: XP-Style selection-rectangle Pin
Blake Miller24-Jun-05 10:19
Blake Miller24-Jun-05 10:19 
GeneralRe: XP-Style selection-rectangle Pin
Luy25-Jun-05 1:56
Luy25-Jun-05 1:56 
GeneralRe: XP-Style selection-rectangle Pin
Blake Miller27-Jun-05 4:17
Blake Miller27-Jun-05 4:17 
GeneralRe: XP-Style selection-rectangle Pin
Luy27-Jun-05 6:15
Luy27-Jun-05 6:15 
GeneralProblem with mixed code of C and C++ Pin
prgr24-Jun-05 3:41
prgr24-Jun-05 3:41 
GeneralRe: Problem with mixed code of C and C++ Pin
Chris Losinger24-Jun-05 5:10
professionalChris Losinger24-Jun-05 5:10 
GeneralRe: Problem with mixed code of C and C++ Pin
Jose Lamas Rios24-Jun-05 9:04
Jose Lamas Rios24-Jun-05 9:04 
GeneralData Scaling Pin
sweep12324-Jun-05 3:36
sweep12324-Jun-05 3:36 
I have to read and store data in a series of unsigned short variables in Shared Memory.

Now these variables are scaled and I need to convert them into their proper units. I display them as either float or integers.

For example for one variable:-
Max Val = 0.999969
Min Val = -1.000000

Least Sig Bit = 0.000030517578 = scaleFactor1.

So what I do is:-

// Get current data item for Shared Memory
unsigned short currentField = *(unsigned short *) fieldPtr; 
float scaleFactor1 = (float)GetScalingFactor(scaleFactorStr);
float rescaledDataEng =  currentField * scaleFactor1;


This works OK (rescaledDataEng ) for positive numbers, but for negative numbers it fails, e.g. I get for -0.44 the incorrect value displayed as (rescaledDataEng = 1.560028).

Are they a neat soultion to this problem other than adjusting for out of range data.

if(rescaledDataEng > maxValue) rescaledDataEng = -(1 -(rescaledDataEng - maxValue));
Also I dont think that I store the data (negative value corectly) when writing to the Sared Memory:-

*(unsigned short *) fieldPtr = (unsigned short)(fEngValue/m_fScalingFactor);

For example for one variable:-
Max Val = 179.999
Min Val = -180.000

Least Sig Bit = 0.005493 = m_fScalingFactor.

I enter -20 and 159.01 is displayed.

Any suggestions please as the more I look at the problem the more confused I get.
GeneralRe: Data Scaling Pin
Budric B.24-Jun-05 5:35
Budric B.24-Jun-05 5:35 
GeneralRe: Data Scaling Pin
Grahamfff24-Jun-05 9:11
Grahamfff24-Jun-05 9:11 
GeneralRe: Data Scaling Pin
liquid_24-Jun-05 9:12
liquid_24-Jun-05 9:12 
GeneralRe: Data Scaling Pin
Grahamfff25-Jun-05 0:03
Grahamfff25-Jun-05 0:03 
GeneralRe: Data Scaling Pin
liquid_26-Jun-05 9:55
liquid_26-Jun-05 9:55 
Generalcasync socket Pin
_tasleem24-Jun-05 3:25
_tasleem24-Jun-05 3:25 
GeneralRe: casync socket Pin
Ravi Bhavnani24-Jun-05 4:44
professionalRavi Bhavnani24-Jun-05 4:44 
GeneralRe: casync socket Pin
Alexander M.,24-Jun-05 10:33
Alexander M.,24-Jun-05 10:33 
GeneralUnique number generation Pin
Hmmkk24-Jun-05 3:13
Hmmkk24-Jun-05 3:13 
GeneralRe: Unique number generation Pin
David Crow24-Jun-05 3:51
David Crow24-Jun-05 3:51 
GeneralRe: Unique number generation Pin
Hmmkk24-Jun-05 4:04
Hmmkk24-Jun-05 4:04 
QuestionMFC and Internet ?? Pin
Rookieee24-Jun-05 3:09
sussRookieee24-Jun-05 3:09 
AnswerRe: MFC and Internet ?? Pin
David Crow24-Jun-05 3:25
David Crow24-Jun-05 3:25 
AnswerRe: MFC and Internet ?? Pin
Ravi Bhavnani24-Jun-05 4:49
professionalRavi Bhavnani24-Jun-05 4:49 
GeneralRe: MFC and Internet ?? Pin
Eytukan24-Jun-05 5:29
Eytukan24-Jun-05 5:29 
GeneralRe: MFC and Internet ?? Pin
Smith#24-Jun-05 5:38
Smith#24-Jun-05 5:38 
GeneralRe: MFC and Internet ?? Pin
Eytukan24-Jun-05 5:40
Eytukan24-Jun-05 5:40 

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.