class Short

namespace sys.core.lang
class Short

A class representing a 16 bit signed integer.

It maps exactly to a 16 bit CPU resource and has no overhead. Because of this strict mapping it can't have extra non-static member variables, can't be inherited from and can't have virtual methods.

Constructors

this

this{string: String};

Brief

Parses a string an constructs a Short based on it.

Parameters

string string to parse

Saturated

this Saturated{value: Int};
this Saturated{value: DWord};
this Saturated{value: Long};
this Saturated{value: QWord};
this Saturated{value: Double};
this Saturated{value: String};

Brief

Constructs a saturated Short based on the input value.

Parameters

value the input value. Can be numeric or a string.

Methods

Clamp

def Clamp(min: Short, max: Short);

Brief

Clamps the current mutable instance between `min` and `max`.

Parameters

min the minimum value
max the maximum value

Clamped

func Clamped(min: Short, max: Short): Short;

Brief

Returns the current instance clamped between `min` and `max`.

Parameters

min the minimum value
max the maximum value

Returns

the clamped value

ToString

func ToString(): String;

Brief

Converts the value to a Utf8 string.

Returns

the resulting string

@write

func @write(ref stream: Stream);
func @write(ref stream: Stream, format: OutputFormat);

Brief

Writes the value to an Utf8 text stream.

Can use an optional output format specifier.

Parameters

stream the output stream
format formatting information

@put

func @put(ref stream: Stream);

Brief

Writes the value to a binary stream as a 16 bit signed integer.

Parameters

stream the output stream

@get

def @get(ref stream: Stream);

Brief

Reads a 16 bit signed integer from a binary stream.

Parameters

stream the input stream

Properties

Abs

property Abs: Short; get;

Brief

Returns the absolute value.


Sqr

property Sqr: Short; get;

Brief

Returns the square of the value value.


Sqrt

property Sqrt: Short; get;

Brief

Returns the square root of the value, rounded down.


Floor

property Floor: Short; get;

Brief

Returns the floor of a floating point value.

In the case of Short it returns the value itself and is included only for API compatibility when using templates.


Ceil

property Ceil: Short; get;

Brief

Returns the ceiling of a floating point value.

In the case of Short it returns the value itself and is included only for API compatibility when using templates.


Round

property Round: Short; get;

Brief

Returns the rounded value of a floating point.

In the case of Short it returns the value itself and is included only for API compatibility when using templates.


Trunc

property Trunc: Short; get;

Brief

Returns the value truncated to the nearest integer value.

In the case of Short it returns the value itself and is included only for API compatibility when using templates.

Constants

Zero

const Zero: Short;

Brief

A Short instance representing a logical "0" value.


One

const One: Short;

Brief

A Short instance representing a logical "1" value.


Min

const Min: Short;

Brief

The minimum value for a Short (16 bit signed integer) instance.


Max

const Max: Short;

Brief

The maximum value for a Short (16 bit signed integer) instance.


IsSigned

const IsSigned;

Brief

true if the numeric representation uses two's complement signed values, false otherwise.


IsInteger

const IsInteger;

Brief

true if the numeric representation is an integer, false if it is a floating point.


MaxDigitsLow

const MaxDigitsLow;

Brief

The lower limit for the number of base 10 digits that are needed to represent a maximal value in textual form.

In base 10, you can have MaxDigitsLow digits that go through values 0-9.

Should not be used for buffer sizes.


MaxDigitsHigh

const MaxDigitsHigh;

Brief

The upper limit for the number of base 10 digits that are needed to represent a maximal value in textual form.

In base 10, the `MaxDigitsHigh - MaxDigitsLow` most significant digits can't go through values 0-9 because they do not fit the binary representation.


Should not be used for buffer sizes.