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¶
Converts an int8 value into its decimal string representation.
Internally, the value is converted to int64 and formatted using the int64 implementation.
int16¶
Converts an int16 value into its decimal string representation.
Internally, the value is converted to int64 and formatted using the int64 implementation.
int32¶
Converts an int32 value into its decimal string representation.
Internally, the value is converted to int64 and formatted using the int64 implementation.
int64¶
Converts an int64 value into its decimal string representation.
Examples¶
Result:
Result:
Result:
Display Implementation¶
All signed integer types implement the Display interface.
This allows integer values to be used with formatting and output functions.
Example¶
Output:
Formatting¶
Integer values can be used with Format().
Example¶
Result:
Notes¶
- All conversions produce decimal output.
- Negative numbers are prefixed with
-. - Zero is represented as
"0". int8,int16, andint32use theint64formatter internally.- A new string is allocated for each conversion.