Click here to Skip to main content
15,916,702 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: HTTP proxy example Pin
alex.barylski13-Nov-03 16:41
alex.barylski13-Nov-03 16:41 
Generalserial communication Pin
codekey13-Nov-03 12:17
codekey13-Nov-03 12:17 
GeneralRe: serial communication Pin
Peter Molnar13-Nov-03 13:31
Peter Molnar13-Nov-03 13:31 
Generalsetting focus to edit controls Pin
RalfPeter13-Nov-03 11:47
RalfPeter13-Nov-03 11:47 
GeneralRe: setting focus to edit controls Pin
alex.barylski13-Nov-03 12:54
alex.barylski13-Nov-03 12:54 
GeneralRe: setting focus to edit controls Pin
RalfPeter13-Nov-03 13:02
RalfPeter13-Nov-03 13:02 
GeneralRe: setting focus to edit controls Pin
Ravi Bhavnani13-Nov-03 13:47
professionalRavi Bhavnani13-Nov-03 13:47 
GeneralScaled float to int conversion Pin
Grahamfff13-Nov-03 10:12
Grahamfff13-Nov-03 10:12 
I need to send data out in two short ints in a message. The source data is in floating representation, range -180.00 to +180.00. This needs to be converted into a scaled 32 bit 2's Complement integer value

So what I need to do is normalise the data;

i.e. float f = 99.9;
f = f/180; // 0.555

Now I need to extract the bits that reprsent the .555 and convert them to a 32 bit bit 2's Complement integer

I was planning to use the union as follows:

union
{
int intValue;
unsigned short buff[2];
}convert;

So once I have converted the float to int I can assign the buff[]

e.g. convert.intValue = floatToInt(f/180);

So now I can load the message using convert.buff[0] and convert.buff[1]

Note I need to check the conversion, so I am planning to do the following:

float f_out = (float) ((buf[0] << 16 | buf[1])*180);

Question how to I convert the float to int?

grahamfff
GeneralRe: Scaled float to int conversion Pin
Tim Smith13-Nov-03 10:56
Tim Smith13-Nov-03 10:56 
GeneralWin32 service problem. Please help Pin
pankajdaga13-Nov-03 10:01
pankajdaga13-Nov-03 10:01 
GeneralRe: Win32 service problem. Please help Pin
Antti Keskinen13-Nov-03 10:32
Antti Keskinen13-Nov-03 10:32 
GeneralRe: Win32 service problem. Please help Pin
pankajdaga13-Nov-03 23:48
pankajdaga13-Nov-03 23:48 
QuestionXML reply from router? Pin
Kuniva13-Nov-03 9:17
Kuniva13-Nov-03 9:17 
GeneralFlatScrollBar Pin
Tzunga Ma13-Nov-03 9:08
sussTzunga Ma13-Nov-03 9:08 
GeneralOutput file Pin
Anonymous13-Nov-03 8:13
Anonymous13-Nov-03 8:13 
GeneralRe: Output file Pin
David Crow13-Nov-03 9:00
David Crow13-Nov-03 9:00 
GeneralRe: Output file Pin
Anonymous13-Nov-03 9:05
Anonymous13-Nov-03 9:05 
GeneralRe: Output file Pin
David Crow13-Nov-03 9:10
David Crow13-Nov-03 9:10 
GeneralStretchDIBits problem with 16-bit (65536) color Pin
tchu13-Nov-03 7:31
tchu13-Nov-03 7:31 
GeneralFloat Roading. Pin
Mike Doner13-Nov-03 7:08
Mike Doner13-Nov-03 7:08 
GeneralRe: Float Roading. Pin
JWood13-Nov-03 8:42
JWood13-Nov-03 8:42 
GeneralMerge sort Pin
Azury13-Nov-03 6:53
Azury13-Nov-03 6:53 
GeneralRe: Merge sort Pin
Dhakad13-Nov-03 20:16
Dhakad13-Nov-03 20:16 
Generalshow fields from a table on a Listbox Control using MFC VC++ Pin
swerajan13-Nov-03 5:32
swerajan13-Nov-03 5:32 
GeneralRe: show fields from a table on a Listbox Control using MFC VC++ Pin
David Crow13-Nov-03 9:04
David Crow13-Nov-03 9:04 

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.