cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
memcpy function
memcpy function
Dec 3, 2008 at 8:49am UTC
Alena
(2)
Hello,
I have the following sequence:
unsigned char buffer[4];
buffer[0] = 0x00;
buffer[1] = 0x00;
buffer[2] = 0x20;
buffer[3] = 0x41;
Then I copy memory to the value VAL with a float type:
float val = 0;
memcpy(&val, &buffer, sizeof(buffer));
And '10.0' is returned as a result.
Please, explain me why the result is 10.0?
Dec 3, 2008 at 10:17am UTC
mahlerfive
(119)
Floating point numbers are stored a bit differently than integers since they have to support decimals. Look up floating point representation on google or wikipedia to find out exactly how they work.
Dec 3, 2008 at 11:04am UTC
Alena
(2)
Thank you a lot :-)
Topic archived. No new replies allowed.