"Sputnik" help  
Sputnik Help
TruncMask(<sizeCode>)

Description

Generates a truncation mask based on the specified size code.

Parameters

<value> The value to be truncated.
<sizeCode> The size code that represents the target size for truncation.

Return Value

Success: Returns the truncation mask value.
Failure: Returns null.

Remarks

The TruncMask function generates a truncation mask based on the specified size code. The size code is typically represented by constants such as @SizeCodeByte or @SizeCodeWord in Sputnik.

The internal implementation of the function uses the SignMask function to obtain the sign mask for the specified size code. It combines the sign mask with its bitwise complement (minus 1) using the bitwise OR operation (|). This creates a mask where all bits beyond the size code are set to 1, effectively truncating any values to fit within the specified size.

Related

Example

Example of usage:

my $sizeCode = @SizeCodeWord;
my $mask = TruncMask($sizeCode);
say $mask;

// PRINTS
// 65535

 


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