"Sputnik" help  
Sputnik Help
IntByteCount(<value>)

Description

Calculates the number of bytes required to represent a signed integer.

Parameters

<value> The signed integer for which the byte count is to be determined.

Return Value

Success: Returns an integer representing the number of bytes required to represent the signed integer.
Failure: Returns null.

Remarks

This function determines the byte count required to represent a signed integer. It iteratively shifts the value to the right by 8 bits until the value becomes less than or equal to 0xFF (one byte) or the maximum byte count of 16 is reached. Each shift operation reduces the value by one byte, and the digit count is incremented. The function stops shifting and returns the digit count once the value can fit within one byte or the maximum byte count is reached.

Related

Example

Example of usage:

say IntByteCount(0x11);
say IntByteCount(0x1122);
say IntByteCount(0x112233);
say IntByteCount(0x11223344);
say IntByteCount(0x1122334455);
say IntByteCount(0x112233445566);
say IntByteCount(0x11223344556677);
say IntByteCount(0x1122334455667788);

// PRINTS
// 1
// 2
// 3
// 4
// 5
// 6
// 7
// 8

 


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org