electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

Char Array to double


Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> Char Array to double
Author Message
ernytony



Joined: 30 Jun 2005
Posts: 13


Post30 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


Post30 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


Post30 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


Post30 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? Very Happy
Back to top
Google
AdSense
Google Adsense




Post30 Jun 2005 10:43   

Ads




Back to top
ernytony



Joined: 30 Jun 2005
Posts: 13


Post30 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


Post05 Jul 2005 8:22   

Re: Char Array to double


will work 100% if size of double is 4 bytes
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> Char Array to double
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
convert double to char array (3)
how to add int in some char array (1)
float to char (8)
char=int (9)
custom char LCD (1)
Graphics on Char LCD? (4)
Mux with comma char (3)
Convert float to char in 89C51 (3)
display char in graphic LCD (1)
Strange behavior of char lcd 4-bit (6)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS