| Author |
Message |
ernytony
Joined: 30 Jun 2005 Posts: 13
|
30 Jun 2005 9:38 Char Array to double |
|
|
|
|
Hi,
this is my problem:
I have a char array (it contains 4 bytes rappresenting a double) , how can I read this array like a double value?
Thanks in advance folks
P.S. I'm working on a PIC 16F877.
|
|
| Back to top |
|
 |
asahin11
Joined: 20 Jun 2005 Posts: 57 Helped: 3
|
30 Jun 2005 10:14 Re: Char Array to double |
|
|
|
|
Hi ernytony,
I am not sure, but you can use "(double)" fornt of array, char variable convert to double. For example ;
char array[4];
(double)array[0];
so char array[0] is converted to double. Good luck
|
|
| Back to top |
|
 |
ernytony
Joined: 30 Jun 2005 Posts: 13
|
30 Jun 2005 10:41 Re: Char Array to double |
|
|
|
|
dear asahin11,
the all 4 bytes array of char is the rappresentation of the unique value of my double number, to say that every char is a byte of my 4 bytes rappresentation value in double, so I need to convert all the array like a unique double value.
Thanks
[/code]
|
|
| Back to top |
|
 |
JankoMuzyk
Joined: 04 Apr 2005 Posts: 46 Helped: 5 Location: Poland
|
30 Jun 2005 10:43 Re: Char Array to double |
|
|
|
|
| Code: |
char tab[4]; // -- it's your table
double doubleVal = *(double *)tab; // assingn value from your tab to variable doubleVal
|
this is what You want?
|
|
| Back to top |
|
 |
Google AdSense

|
30 Jun 2005 10:43 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
ernytony
Joined: 30 Jun 2005 Posts: 13
|
30 Jun 2005 13:06 Re: Char Array to double |
|
|
|
|
It was just what I need
Thanks
|
|
| Back to top |
|
 |
chints
Joined: 04 Jul 2005 Posts: 5
|
05 Jul 2005 8:22 Re: Char Array to double |
|
|
|
|
| will work 100% if size of double is 4 bytes
|
|
| Back to top |
|
 |