parts2single

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

creates a single float from a int exponent (0 255) and a 24 Bit integer mantisse



See Also: code3Byte2single , single2parts

Example Illustration

 missing image of parts2single(e,m)

Syntax

k=parts2single(e,m)

Input Parameter

e: exponent/code
m: 24 Bit integer

Output Parameter

k: single precision float

Examples


parts2single(110,1234)
[a,b]=single2parts(parts2single(110,1234))




Copyright 2020-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

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.

Input Parameters

Output

Algorithm Steps

  1. Create a quantizer object for single precision using quantizer('single'). This sets up the format for conversion.
  2. Convert the exponent 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.
  3. Convert the absolute value of the mantissa 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.
  4. Determine the sign bit sb. If m is negative, set sb to '1'; otherwise, set it to '0'.
  5. Combine the sign bit, exponent, and mantissa into a single binary string.
  6. Convert the combined binary string into a single precision floating-point number using 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)

Last html export of this page out of FM database by TL: 2025-09-21