Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4   7.5   7.6    Statistic  

Math.EncodeNumber

Encodes a number as binary data as hex text.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
Math 6.4 Yes Yes Yes Yes Yes

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

Parameters

Parameter Description Example value
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 Optional
Pass 1 to encode big endian.
Default is 0 for little endian.
0

Result

Returns hex text or error.

Description

Encodes a number as binary data as hex text.
You can use Math.DecodeNumber 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 ) & ¶ & MBS( "Math.EncodeNumber"; "Float"; 32; 123,456; 0 )

Encode number with big endian and extended to 16 bytes:

"000000000000000000000000" & MBS( "Math.EncodeNumber"; "Integer"; 32; 1234567;1 )

See also


Math.DecodeNumber   -   Math.HexToDec

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins