??? 07/01/06 10:18 Read: times |
#119508 - again Responding to: ???'s previous message |
David Brown said:
Viewing the dissasembly in Keil shows it produces good code That's always a risky approach - you should always confirm in the Manual that it is guaranteed to produce the code you require every time! temp[0] = ((unsigned char*)(&f))[0]; temp[1] = ((unsigned char*)(&f))[1];This is effectively the same as I suggested here: http://www.8052.com/forum/read.phtml?id=119416 , though somewhat less general. Note that char* is the old-style K&R idiom for a "pointer to anything" (sometimes called a "generic" pointer) - the modern, ANSI, idiom is void* See also: http://www.8052.com/forum/read.phtml?id=116048 note that you'll have to make sure to get the byte order correct. In many cases - most likely including this one - this doesn't matter; again, see: http://www.8052.com/forum/read.phtml?id=119416 |
Topic | Author | Date |
Integarting and disintgration of float | 01/01/70 00:00 | |
Float to Byte | 01/01/70 00:00 | |
use a union? | 01/01/70 00:00 | |
Use a union, but ... | 01/01/70 00:00 | |
Might not matter... | 01/01/70 00:00 | |
Unwarranted assuption | 01/01/70 00:00 | |
thanks a lot | 01/01/70 00:00 | |
you can also try.... | 01/01/70 00:00 | |
again![]() | 01/01/70 00:00 |