class PtrSize

namespace sys.core.lang
class PtrSize

A class representing a size of a pointer or an offset withing a pointer.

It is an unsigned value. It can be 32 or 64 bits long, depending on the target architecture.

It maps exactly to a 32/64 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.

Methods

Clamp

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

Brief

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

Parameters

min the minimum value
max the maximum value

Clamped

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

Brief

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

Parameters

min the minimum value
max the maximum value

Returns

the clamped value

@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 32/64 bit unsigned integer.

Parameters

stream the output stream

@get

def @get(ref stream: Stream);

Brief

Reads a 32/64 bit unsigned integer from a binary stream.

Parameters

stream the input stream

Properties

Abs

property Abs: PtrSize; get;

Brief

Returns the absolute value.

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


Sqr

property Sqr: PtrSize; get;

Brief

Returns the square of the value value.


Sqrt

property Sqrt: PtrSize; get;

Brief

Returns the square root of the value, rounded down.


Floor

property Floor: PtrSize; get;

Brief

Returns the floor of a floating point value.

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


Ceil

property Ceil: PtrSize; get;

Brief

Returns the ceiling of a floating point value.

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


Round

property Round: PtrSize; get;

Brief

Returns the rounded value of a floating point.

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

Constants

Zero

const Zero: PtrSize;

Brief

A PtrSize instance representing a logical "0" value.


One

const One: PtrSize;

Brief

A PtrSize instance representing a logical "1" value.


Min

const Min: PtrSize;

Brief

The minimum value for a PtrSize (32/64 bit unsigned integer) instance.


Max

const Max: PtrSize;

Brief

The minimum value for a PtrSize (64 bit signed integer) instance.


Invalid

const Invalid: PtrSize;

Brief

The value signaling invalid/out of bounds.


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 though 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 though values 0-9 because they do not fit the binary representation.


Should not be used for buffer sizes.