"Sputnik" help  
Sputnik Help
TruncateSize(<value>, <sizeCode>)

Description

Truncates a value to fit within a 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 true.
Failure: Returns false.

Remarks

The TruncateSize function truncates a value to fit within the specified size code. It performs a bitwise AND operation between the value and the truncation mask determined by the size code.

The internal implementation of the function uses the TruncMask function to obtain the truncation mask. The truncation mask is generated by combining the sign mask (obtained from the SignMask function) with its bitwise complement (minus 1). This creates a mask where all bits beyond the size code are set to 1, effectively truncating the value.

Related

Example

Example of usage:

my $value = 0b111100001111;
my $sizeCode = @SizeCodeWord;
my $truncated = TruncateSize($value, $sizeCode);
say $truncated;

// PRINTS
// 3855

 


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