GetFloatBit('Expression','BitNo')
Arguments
|
'Expression' |
Any number |
|
'BitNo' |
This number (0…15 or 0…31) specifies the position of the desired digital signal in a 16-bit or 32-bit block in the data stream with regard to the related offset address. Increase of bit no. by 1 up to 15 (31), then increase of address by 2 (4). |
Description
This function interprets 'Expression' as the bitmask of a float value and returns as its result the Boolean value of the 'BitNumber' bit of 'Expression'. Valid bit number sequence: 0 (LSB) to 31 (MSB).
This function was created especially for the case that 32 bits are packed in a float data for transmission or recording. The GetBitFloat function only takes the value of the specified 'BitNo' bit regardless of whether it is part of the mantissa or exponent. Unlike the GetBit function, there is no rounding of values.
Example
A value entered in 'Expression' is converted to the floating-point format IEEE 754 and the digits bits which are set to TRUE accordingly, are retrieved.
Solution
Floating-point numbers according to the IEEE 754 format can generally be written as follows: (sign)*mantissa*10^Exponent
The number 0.15625 reads as a floating-point number according to IEEE 754 as follows:
|
Sign (1 bit) |
Exponent (8 bit) |
Mantisse (23 bit) |
|
0 |
0111 1100 |
0100 0000 0000 0000 0000 000 |
In this case, the LSB (least significant bit) is at the extreme right point.
Tip |
|
|---|---|
|
Floating-point numbers according to the IEEE 754 format are written in the manner shown. The following points for the individual components should be noted: Sign: 0 stands for positive; 1 for negative Exponent: Since with the conversion to a floating-point number, the exponent value is shifted by 127, 127 must be subtracted from the displayed exponent in the conversion into a decimal number. Mantissa: Because the mantissa has a 1 before the decimal point by default, this digit is no longer represented. All mantissa digits are therefore decimal digits and must take into account the conversion with negative exponents to base 2. |
|
The figure below shows the retrieval of the valence of selected bits of the float value of 0.15625.
