Math.DecodeNumber
-----------------

Decodes a number from it's binary representation.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Math](component_Math.md) | [6.4](newinversion64.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Math.DecodeNumber"; NumberType; Bits; Text { ; BigEndian } ) 

**MBS**( **"Math.DecodeNumber";** /\* Decodes a number from it's binary representation. \*/  
**$NumberType**; /\* Which type of number to encode.  
Can be "Float", "Integer" or "UnsignedInteger".e.g. "Float" \*/   
**$Bits**; /\* The number of bits.  
Can be 32 or 64 for float.  
Can be 8, 16, 24, 32 or 64 for integers.e.g. 32 \*/   
**$Text**; /\* The hex encoded binary data.e.g. "14EF" \*/   
**$BigEndian**) /\* Optional; Pass 1 to encode big endian.  
Default is 0 for little endian.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| NumberType | Which type of number to encode.   Can be "Float", "Integer" or "UnsignedInteger". | "Float" |  |
| Bits | The number of bits.   Can be 32 or 64 for float.   Can be 8, 16, 24, 32 or 64 for integers. | 32 |  |
| Text | The hex encoded binary data. | "14EF" |  |
| BigEndian | Pass 1 to encode big endian.   Default is 0 for little endian. | 0 | Optional |

### Result

Returns number or error.

### Description

Decodes a number from it's binary representation.  
This may be useful for binary protocols with serial ports or sockets.  
### Examples

Decodes a 32-bit floating point number:

 MBS ( "Math.DecodeNumber"; "Float"; 32; "79E9F642" )  
Decode a 8-bit integer number:

 MBS ( "Math.DecodeNumber"; "Integer"; 8; "C8")  
Decode a 64-bit unsigned integer:

 MBS ( "Math.DecodeNumber"; "UnsignedInteger"; 64; "C0BA8A3CD5620400")  
Decode big endian 64-bit:

 MBS ( "Math.DecodeNumber"; "Integer"; 64; "0000000000000001"; 1)  
### See also

- [Archive.GZipDecompress](ArchiveGZipDecompress.md)
- [Math.EncodeNumber](MathEncodeNumber.md)
- [Math.TextToNumber](MathTextToNumber.md)
- [Text.ReadTextFromContainer](TextReadTextFromContainer.md)

### Blog Entries

- [MBS FileMaker Plugin, version 6.4pr3](https://www.mbsplugins.de/archive/2016-08-08/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.4pr1](https://www.mbsplugins.de/archive/2016-07-20/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 14th July 2016 , last changed 30th January 2023

  
[Math.DecToHex](MathDecToHex.md) - [Math.EncodeNumber](MathEncodeNumber.md)

[HTML Version](MathDecodeNumber.shtml)