You are here:

C++/On BYTE & float

Advertisement


Question
hello
how will i put float value in a BYTE array and then store in  memory.Array length allocation should be dynamic & how will i retriev.
i am a final year BE student Doing project on smart cards.i want store Float value like Academic percentage in card memory.
waiting for reply
kiran

Answer
Hi,
 As you know that float size is more than what could be fitted in a BYTE. So if you have to store 1 float then you have to allocate :

sizeof(float)/sizeof(BYTE) sized BYTE array to store the values.

Another way (not goodm but can be atoned): if the value before and after "." is not more than 1 BYTE then you could split a float in 2 BYTES.


Regards,
RaiD

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Dharmender Rai

Expertise

I can answer general and system level C/C++ questions.

Experience

I have 5 years of experience in C++.

©2016 About.com. All rights reserved.