Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to read a char array like a double value?

Status
Not open for further replies.

ernytony

Newbie level 6
Joined
Jun 30, 2005
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,376
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.
 

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
 

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]
 

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? :D
 

Re: Char Array to double

It was just what I need
Thanks
 

Re: Char Array to double

will work 100% if size of double is 4 bytes
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top