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

Description

Generates a sign mask based on the specified size code.

Parameters

<sizeCode> The size code that represents the target size for the sign mask.

Return Value

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

Remarks

The SignMask function generates a sign 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 calculates the position of the sign bit based on the size code. It shifts the value 1ul (unsigned long) to the left by the position of the sign bit, which is determined by (8 << sizeCode) - 1. This creates a mask where only the sign bit is set.

Related

Example

Example of usage:

my $sizeCode = @SizeCodeByte;
my $mask = SignMask($sizeCode);
say $mask;

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

my $sizeCode = @SizeCodeDWord;
my $mask = SignMask($sizeCode);
say $mask;

my $sizeCode = @SizeCodeQWord;
my $mask = SignMask($sizeCode);
say $mask;

// PRINTS
// 128
// 32768
// 2147483648
// 9223372036854775808

 


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