by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 5.0, Creation date: 2020-11-29, Last change: 2025-09-15
See Also: code3Byte2single
, single2parts
k=parts2single(e,m)
e: | exponent/code | |
m: | 24 Bit integer |
k: | single precision float |
parts2single(110,1234)
[a,b]=single2parts(parts2single(110,1234))
This function, parts2single, converts an integer exponent and a 24-bit integer mantissa into a single precision floating-point number. It is part of the SolidGeometry library and was introduced in version 5.0.
quantizer('single'). This sets up the format for conversion.e to an 8-bit binary string using dec2bin(e,8). If the resulting string has more than 8 bits, an error is thrown indicating the exponent is too large.m to a 23-bit binary string using dec2bin(abs(m),23). If the resulting string has more than 23 bits, an error is thrown indicating the mantissa is too large.sb. If m is negative, set sb to '1'; otherwise, set it to '0'.bin2float(q,[sb eb mb]).This function is useful for converting parts of a floating-point number into a single precision format, which is commonly used in various computational applications.
Algorithm explaination created using ChatGPT on 2025-08-18 23:21. (Please note: No guarantee for the correctness of this explanation)