Skip to content

Integer Types

Signed integer types represent whole numbers that may be positive, negative, or zero.

Module: Std

Summary

ToString(value: int8) -> String
ToString(value: int16) -> String
ToString(value: int32) -> String
ToString(value: int64) -> String

int8.ToString() -> String
int16.ToString() -> String
int32.ToString() -> String
int64.ToString() -> String

Description

Rux provides multiple signed integer types:

Type Size Range
int8 8 bits -128 to 127
int16 16 bits -32,768 to 32,767
int32 32 bits -2,147,483,648 to 2,147,483,647
int64 64 bits -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

All integer types implement the Display interface.


String Conversion

ToString

int8

ToString(value: int8) -> String

Converts an int8 value into its decimal string representation.

Internally, the value is converted to int64 and formatted using the int64 implementation.


int16

ToString(value: int16) -> String

Converts an int16 value into its decimal string representation.

Internally, the value is converted to int64 and formatted using the int64 implementation.


int32

ToString(value: int32) -> String

Converts an int32 value into its decimal string representation.

Internally, the value is converted to int64 and formatted using the int64 implementation.


int64

ToString(value: int64) -> String

Converts an int64 value into its decimal string representation.

Examples

ToString(42);

Result:

42
ToString(-123);

Result:

-123
ToString(0);

Result:

0

Display Implementation

All signed integer types implement the Display interface.

extend int8  : Display
extend int16 : Display
extend int32 : Display
extend int64 : Display

This allows integer values to be used with formatting and output functions.

Example

PrintLine(42);

Output:

42

Formatting

Integer values can be used with Format().

Example

let score: int32 = 9001;

let text = Format(
    "Score: {}",
    score
);

Result:

Score: 9001

Notes

  • All conversions produce decimal output.
  • Negative numbers are prefixed with -.
  • Zero is represented as "0".
  • int8, int16, and int32 use the int64 formatter internally.
  • A new string is allocated for each conversion.