Math: ConvertToFloat16MBS

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

ConvertToFloat16MBS(Number as Single) as UInt16

Type Topic Plugin Version macOS Windows Linux iOS Targets
global method Math MBS Util Plugin 15.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Converts a 32bit floating point number to a 16bit floating point number.
Example
dim h1 as UInt16 = ConvertToFloat16MBS(1.0)
dim f1 as single = ConvertFromFloat16MBS(h1) // should be 1.0


dim h2 as UInt16 = ConvertToFloat16MBS(-1.0)
dim f2 as single = ConvertFromFloat16MBS(h2) // should be -1.0


dim h3 as UInt16 = ConvertToFloat16MBS(1000.0)
dim f3 as single = ConvertFromFloat16MBS(h3) // should be 1000.0


dim h4 as UInt16 = ConvertToFloat16MBS(-1000.0)
dim f4 as single = ConvertFromFloat16MBS(h4) // should be -1000.0


dim inf as single = 65504.0
dim h5 as UInt16 = ConvertToFloat16MBS(inf)
dim f5 as single = ConvertFromFloat16MBS(h5) // should be 65504


dim nan as single = sqrt(-1)
dim h6 as UInt16 = ConvertToFloat16MBS(nan)
dim f6 as single = ConvertFromFloat16MBS(h6) // should be NAN


Break // check in debugger

This looses precision as 16bit fit less bits than 32 bit.

Blog Entries

The items on this page are in the following plugins: MBS Util Plugin.


💬 Ask a question or report a problem