Math.EncodeNumber
-----------------

Encodes a number as binary data as hex text.

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

MBS( "Math.EncodeNumber"; NumberType; Bits; Number { ; BigEndian } ) 

**MBS**( **"Math.EncodeNumber";** /\* Encodes a number as binary data as hex text. \*/  
**$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 \*/   
**$Number**; /\* The number to encode.e.g. 123 \*/   
**$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 |  |
| Number | The number to encode. | 123 |  |
| BigEndian | Pass 1 to encode big endian.   Default is 0 for little endian. | 0 | Optional |

### Result

Returns hex text or error.

### Description

Encodes a number as binary data as hex text.  
You can use [Math.DecodeNumber](MathDecodeNumber.md) to decode it again.  
### Examples

Encodes a 32-bit floating point number:

 MBS ( "Math.EncodeNumber"; "Float"; 32; 123.456 )   
// 79E9F642  
Encode 8 bit signed integer:

 MBS ( "Math.EncodeNumber"; "Integer"; 8; -56 )  
// C8  
Encode 64-bit unsigned integer:

 MBS ( "Math.EncodeNumber"; "UnsignedInteger"; 64; 1234567890123456)  
// C0BA8A3CD5620400  
Encodes number with big/little endian:

 MBS ( "Math.EncodeNumber"; "Float"; 32; 123,456; 1 ) &amp; ¶ &amp; MBS ( "Math.EncodeNumber"; "Float"; 32; 123,456; 0 )  
Encode number with big endian and extended to 16 bytes:

 "000000000000000000000000" &amp; MBS ( "Math.EncodeNumber"; "Integer"; 32; 1234567;1 )  
### See also

- [Math.DecodeNumber](MathDecodeNumber.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.DecodeNumber](MathDecodeNumber.md) - [Math.FormatNumber](MathFormatNumber.md)

[HTML Version](MathEncodeNumber.shtml)