11-12-2010 02:00 PM
Hello,
I have a to convert a float number to U8 array format how to do this ?
example 0.6 should be XX XX XX XX.
1.2 should be YY YY YY YY
array size should be 4 only.
I did try using string to byte array function but I do not know whether it is proper or not?
because for 1.2 I got the answer as 49 46 50 (byte 0,1,2)
Thanks
Solved! Go to Solution.
11-12-2010 02:19 PM
Is this what you are looking for?
11-12-2010 02:28 PM
Well if you type 0.35 as input number the type cast gives me array size of 16.
I need to convert 0.35 (or any number) to array format but array size should only be 4 & when I reconvert array I should get back the same input number.
11-12-2010 02:35 PM
The size of a single float is only 4 bytes.
Your starting data type must be bigger than a Single. A double is only 8 bytes.
What data type are you using as your input?
The example will only give you 4 bytes no matter what number you type in.
11-12-2010 03:11 PM
@systemcrash wrote:
Well if you type 0.35 as input number the type cast gives me array size of 16.
I need to convert 0.35 (or any number) to array format but array size should only be 4 & when I reconvert array I should get back the same input number.
What is the data type of your FLOAT? Single is 4 bytes, Double is 8
I do not know where you are getting an array size of 16
Is this what your are trying to get the 32 bits of a Single Float?
Single-precision floating-point numbers have a 32-bit IEEE single-precision format.
Put .35 in and you get .35 back
11-12-2010 03:43 PM
I think I overlooked some stuff,
Thank you Omar II
11-12-2010 04:04 PM
@Omar II wrote:
I do not know where you are getting an array size of 16
That would be an EXT data type