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

Description

Sign-extends a value to a larger size based on the specified size code.

Parameters

<value> The value to be sign-extended.
<sizeCode> The size code that represents the target size for sign extension.

Return Value

Success: Returns the sign-extended value.
Failure: Returns null.

Remarks

The SignExtend function takes the original value and extends its sign to fit a larger size based on the specified size code. The size code is typically represented by constants such as @SizeCodeDWord in Sputnik.

The internal implementation of the function checks if the original value has a positive sign (based on the size code), and if so, returns the original value unchanged. If the value has a negative sign, the function performs a bitwise OR operation with the bitwise complement of the truncation mask (obtained from the size code) to extend the sign.

Related

Example

Example of usage:

my $value = -10;
my $sizeCode = @SizeCodeQWord;
my $extended = (^Int64)SignExtend($value, $sizeCode);
say $extended;

// PRINTS
// -10

 


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