There are a number of opportunities to get this wrong. All so you nee to be sure that the transmission order of the bits is is the same order in which you are reassembling them. If they differ your code may have to do one or both of reorder the bits and calculate the floating point equivalent by extraction of exponent and mantissa. Not only must the FP representation be identical but also the endianness. It is all a bit non-portable, The fact that your code does not work suggests perhaps that the representation does indeed differ between sender and receiver. However this does require that the floating point representation of the originator is identical to that of the receiver which may not be a given. The intermediate result in transport_bits is target dependent, in my test on x86, it is 0x449a522b, this being the bit representation of single precision float on that platform (floating point representation and endianness dependent).Įither way the result in destination_float is identical to source_float having been transported via the uint32_t transport_bits. Australia/NewZealand Men's Pants/Trousers 32/82 Europe Men's Pants/Trousers 48 Italy/France/Spain Men's Pants/Trousers 42 International Size in Centimetres Men's Pants/Trousers 81 China Men's Pants/Trousers 170/82A Reference Dimension(CM) Waist: 81. Uint32_t transport_bits = *((uint32_t*)&source_float) įloat destination_float = *((float*)&transport_bits) The simplest way to do that is to take the address of the data and reinterpret it as a pointer to the intermediate "carrier" type before dereferencing it.Ĭonsider this: float source_float = 1234.5678f You need to copy the bit pattern verbatim without invoking any implicit conversions. Should I store the received bits to a char array and then convert it to float. Is there some other method to convert 32-bits of data to a float. So after the demodulation I am expecting the float array output to have a same values as data array. Now, the values of the output array are just the values of outData array with 0s after the decimal point.Įxample: if output=12345 the `outData=12345.0000'.īut while testing the program I am generating the sample test data of bits using an array of floatįloat data = If(i!=0 & (bitsCounter%32)=0) //32-bits processed, save the data in array Unint32_t *outData //this is intiallized to address of some pre-defined location in DSP memory Right I am doing something like : uint32_t i,j,curBit,curBlk So, I need to pack every set of 32 bits received to form a float value. But I have to return the data for processing in the form of a float array. Right now, I am able to detect the bits individually. On the receiver part of the program, I am getting an input of a set of samples which I de-modulate using Goertzel algorithm to determine whether the received bit was a 0 or 1. The copy-paste of the page "ASCII Code" or any of its results, is allowed as long as you cite dCode!Ĭite as source (bibliography): ASCII Code on dCode.I am working on a DSP processor to implement a BFSK frequency hopping mechanism using C on a Linux system. The copy-paste of the page "ASCII Code" or any of its results, is allowed as long as you cite the online source Except explicit open source licence (indicated Creative Commons / free), the "ASCII Code" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or the "ASCII Code" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "ASCII Code" are not public, same for offline use on PC, tablet, iPhone or Android ! (Unit non-visible characters are control characters (see ASCII table from 1 to 31) Ask a new question Source codeĭCode retains ownership of the "ASCII Code" source code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |