Does mikroc support Type casting

Discuss with MikroElektronika software developers about current library development.
Post Reply
Author
Message
umut3502
Posts: 28
Joined: 13 Sep 2006 00:52

Does mikroc support Type casting

#1 Post by umut3502 » 08 Feb 2013 15:30

I am trying to cast from double to char because I should send the variable to flash memory as char that s why I have to cast my double variable to char
How can I achieve type casting

Another question is double is 4 byte char is 1 byte how is that casting possible

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: Does mikroc support Type casting

#2 Post by janni » 08 Feb 2013 19:05

umut3502 wrote:Another question is double is 4 byte char is 1 byte how is that casting possible
Casting is, well, casting and as such cannot preserve type. What you need is accessing the four bytes constituting double, one by one. You may form a union of a double and array of four bytes/chars (thus both will use the same space in RAM) or use the Lo, Hi, Higher and Highest operators defined in built_in.h (add "#include <built_in.h>" to your project). See compiler's Help for details.

Post Reply

Return to “Library Development Discussion”